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