update
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
import os
|
||||
import subprocess
|
||||
from swayipc import Swayipc
|
||||
|
||||
|
||||
def get_base():
|
||||
return os.environ.get("BASE_SWAY", os.path.expanduser("~/.config/sway"))
|
||||
|
||||
from warehouse import get_base
|
||||
|
||||
Logs = "/tmp/sway_boot.log"
|
||||
|
||||
|
||||
def apply_safe_config(sway):
|
||||
try:
|
||||
sway.cmd("default_border pixel 0")
|
||||
sway.cmd("floating_modifier Mod4")
|
||||
sway.cmd("bindsym Mod4+Shift+grave reload")
|
||||
sway.cmd("bindsym Mod4+Shift+escape exit")
|
||||
|
||||
@@ -7,15 +7,11 @@ import tempfile
|
||||
import base64
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from warehouse import Media_flag, rand12
|
||||
|
||||
Recording_flag = "/tmp/screenshot_active"
|
||||
Recordings = Path.home() / "records"
|
||||
Tmp = tempfile.gettempdir()
|
||||
|
||||
def rand12():
|
||||
return base64.urlsafe_b64encode(os.urandom(9)).decode()[:12]
|
||||
|
||||
|
||||
def run(cmd):
|
||||
return subprocess.run(cmd)
|
||||
|
||||
@@ -46,7 +42,6 @@ def force_kill():
|
||||
pid = find_focused_pid(tree)
|
||||
|
||||
if not pid:
|
||||
print("No focused window PID found")
|
||||
return
|
||||
|
||||
os.kill(pid, 9)
|
||||
@@ -65,12 +60,12 @@ def record(fullscreen=False):
|
||||
if is_recording():
|
||||
subprocess.run(["killall", "wf-recorder"])
|
||||
try:
|
||||
os.remove(Recording_flag)
|
||||
os.remove(Media_flag)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return
|
||||
|
||||
Path(Recording_flag).write_text("1")
|
||||
Path(Media_flag).write_text("1")
|
||||
|
||||
slurp_cmd = ["slurp"]
|
||||
if fullscreen:
|
||||
@@ -130,7 +125,7 @@ def resolve_output(out):
|
||||
|
||||
|
||||
def take_screenshot(output_path):
|
||||
Path(Recording_flag).write_text("1")
|
||||
Path(Media_flag).write_text("1")
|
||||
|
||||
try:
|
||||
time.sleep(0.2)
|
||||
@@ -164,7 +159,7 @@ def take_screenshot(output_path):
|
||||
|
||||
finally:
|
||||
try:
|
||||
os.remove(Recording_flag)
|
||||
os.remove(Media_flag)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -6,11 +6,7 @@ import struct
|
||||
import subprocess
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
vpncache = Path("/tmp/vpn_country.cache")
|
||||
screenshotflag = Path("/tmp/screenshot_active")
|
||||
|
||||
from warehouse import Vpn_cache, Media_flag
|
||||
|
||||
class Cached:
|
||||
def __init__(self, ttl):
|
||||
@@ -93,13 +89,13 @@ class StatusBar:
|
||||
def get_vpn(self):
|
||||
def compute():
|
||||
if not self.run(["wg", "show", "interfaces"]):
|
||||
if vpncache.exists():
|
||||
vpncache.unlink()
|
||||
if Vpn_cache.exists():
|
||||
Vpn_cache.unlink()
|
||||
return ""
|
||||
|
||||
country = ""
|
||||
if vpncache.exists():
|
||||
country = vpncache.read_text().strip()
|
||||
if Vpn_cache.exists():
|
||||
country = Vpn_cache.read_text().strip()
|
||||
|
||||
if not country:
|
||||
ip = http_get("https://ifconfig.me")
|
||||
@@ -112,7 +108,7 @@ class StatusBar:
|
||||
country = ""
|
||||
|
||||
if country:
|
||||
vpncache.write_text(country)
|
||||
Vpn_cache.write_text(country)
|
||||
|
||||
return f"VPN: {country or 'Unknown'}"
|
||||
|
||||
@@ -125,8 +121,8 @@ class StatusBar:
|
||||
return self.rec.get(compute)
|
||||
|
||||
def get_time(self):
|
||||
if screenshotflag.exists():
|
||||
return "REDACTED"
|
||||
if Media_flag.exists():
|
||||
return "0001-01-01 12:00 AM"
|
||||
return self.run(["date", "+%Y-%m-%d %I:%M %p"])
|
||||
|
||||
def render(self):
|
||||
|
||||
@@ -4,9 +4,7 @@ import sys
|
||||
from swayipc import Swayipc
|
||||
import swayworkspace
|
||||
from pathlib import Path
|
||||
|
||||
def get_base():
|
||||
return os.environ.get("BASE_SWAY")
|
||||
from warehouse import get_base
|
||||
|
||||
def run_sh(c):
|
||||
subprocess.Popen(c, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
@@ -3,6 +3,7 @@ import sys
|
||||
from dataclasses import dataclass
|
||||
from swayipc import Swayipc, Output, Workspace
|
||||
import pathlib
|
||||
|
||||
class SwaySome(Swayipc):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# probably shouldnt mess with this!
|
||||
# boot depends on it and if u break it u get no safe mode.
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
Vpn_cache = Path("/tmp/vpn_country.cache")
|
||||
Media_flag = Path("/tmp/media_active")
|
||||
|
||||
def get_base():
|
||||
return os.environ.get("BASE_SWAY")
|
||||
|
||||
def rand12():
|
||||
return base64.urlsafe_b64encode(os.urandom(9)).decode()[:12]
|
||||
Reference in New Issue
Block a user