stepping it back

This commit is contained in:
2026-07-09 20:00:35 -05:00
parent 2743338c36
commit 53cdebdc1e
17 changed files with 229 additions and 305 deletions
+5
View File
@@ -0,0 +1,5 @@
[Desktop Entry]
Type=Application
Name=Blueman
Exec=blueman-applet
X-GNOME-Autostart-enabled=true
+5
View File
@@ -0,0 +1,5 @@
[Desktop Entry]
Type=Application
Name=kdeconnect
Exec=kdeconnectd
X-GNOME-Autostart-enabled=true
+2
View File
@@ -1,2 +1,4 @@
paste_actions filter
include current-theme.conf
font_family Terminus
font_size 11
+4
View File
@@ -0,0 +1,4 @@
paste_actions filter
include current-theme.conf
font_family Terminus
font_size 10
+4
View File
@@ -29,3 +29,7 @@ let flatpak_xdg = [
$env.XDG_DATA_DIRS = ($base_xdg | append $flatpak_xdg | str join ":")
$env.PATH = ( $env.PATH | split row (char env_sep) | prepend "~/.local/bin" | append "/sbin" | append "/usr/sbin/")
def pfind [name: string] {
ps | where name =~ $name | select name pid
}
+92 -3
View File
@@ -1,8 +1,97 @@
set $base ~/.config/sway/
xwayland enable
exec_always env BASE_SWAY=$base XDG_DATA_DIRS=/var/lib/flatpak/exports/share:$HOME/.local/share/flatpak/exports/share:/usr/local/share:/usr/share /usr/bin/python3 $base/main/boot.py
floating_modifier Mod4
default_border none
default_floating_border none
client.focused #ffffff #ffffff #ffffff #ffffff
client.focused_inactive #000000 #000000 #000000 #000000
client.unfocused #000000 #000000 #000000 #000000
client.urgent #ffffff #ffffff #ffffff #ffffff
client.placeholder #000000 #000000 #000000 #000000
bar top {
position top
status_command python3 $base/main/sway_status.py
font pango:Noto Sans Mono 10
mode dock
colors {
background #000000
statusline #ffffff
separator #ffffff
focused_workspace #000000 #ffffff #000000
active_workspace #000000 #ffffff #000000
inactive_workspace #000000 #000000 #ffffff
urgent_workspace #ffffff #ffffff #ffffff
}
}
for_window [app_id="xpad"] floating enable
exec_always gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
exec_always gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
exec_always gsettings set org.gnome.desktop.interface cursor-size 12
exec_always gsettings set org.gnome.desktop.interface font-name 'Noto Sans Mono 10'
exec_always /usr/lib/xdg-desktop-portal -r
exec_always swaybg -i $base/wallpaper/metrowaymaka.png -m fill
exec_always /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
exec_always dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP SWAYSOCK
bindsym Mod4+h focus left
bindsym Mod4+j focus down
bindsym Mod4+k focus up
bindsym Mod4+l focus right
bindsym Mod4+Shift+h move left
bindsym Mod4+Shift+j move down
bindsym Mod4+Shift+k move up
bindsym Mod4+Shift+l move right
bindsym Mod4+bracketleft workspace prev
bindsym Mod4+bracketright workspace next
bindsym Mod4+q exec kitty
bindsym Mod4+c kill
bindsym Mod4+Shift+s exec python3 $base/main/moves.py screenshot --out ~/screenshots/
bindsym Mod4+Shift+Escape exit
bindsym Mod4+Up exec pamixer --increase 1
bindsym Mod4+Down exec pamixer --decrease 1
bindsym Mod4+Shift+grave reload
bindsym Mod4+Shift+f exec python3 $base/main/moves.py record --fullscreen
bindsym Mod4+r exec wofi --show drun --width 400 --height 500 --layer overlay --location 1
bindsym Ctrl+Shift+Alt+Mod4+L exec flatpak run io.github.ungoogled_software.ungoogled_chromium https://www.linkedin.com
bindsym Mod4+Shift+c exec python3 $base/main/moves.py kill
bindsym Mod4+n exec xpad
bindsym Mod4+v floating toggle
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl play-pause
exec_always python3 $base/main/swayworkspace.py init 1
bindsym Mod4+1 exec python3 $base/main/swayworkspace.py focus 1
bindsym Mod4+Shift+1 exec python3 $base/main/swayworkspace.py move 1
bindsym Mod4+2 exec python3 $base/main/swayworkspace.py focus 2
bindsym Mod4+Shift+2 exec python3 $base/main/swayworkspace.py move 2
bindsym Mod4+3 exec python3 $base/main/swayworkspace.py focus 3
bindsym Mod4+Shift+3 exec python3 $base/main/swayworkspace.py move 3
bindsym Mod4+4 exec python3 $base/main/swayworkspace.py focus 4
bindsym Mod4+Shift+4 exec python3 $base/main/swayworkspace.py move 4
bindsym Mod4+5 exec python3 $base/main/swayworkspace.py focus 5
bindsym Mod4+Shift+5 exec python3 $base/main/swayworkspace.py move 5
bindsym Mod4+6 exec python3 $base/main/swayworkspace.py focus 6
bindsym Mod4+Shift+6 exec python3 $base/main/swayworkspace.py move 6
bindsym Mod4+7 exec python3 $base/main/swayworkspace.py focus 7
bindsym Mod4+Shift+7 exec python3 $base/main/swayworkspace.py move 7
bindsym Mod4+8 exec python3 $base/main/swayworkspace.py focus 8
bindsym Mod4+Shift+8 exec python3 $base/main/swayworkspace.py move 8
bindsym Mod4+9 exec python3 $base/main/swayworkspace.py focus 9
bindsym Mod4+Shift+9 exec python3 $base/main/swayworkspace.py move 9
bindsym Mod4+0 exec python3 $base/main/swayworkspace.py focus 10
bindsym Mod4+Shift+0 exec python3 $base/main/swayworkspace.py move 10
include ~/.config/mute/*
seat seat0 xcursor_theme DMZ-Black 12
exec_always env BASE_SWAY=$base /usr/bin/python3 $base/main/boot.py
seat seat0 xcursor_theme DMZ-Black 12
-49
View File
@@ -1,49 +0,0 @@
import os
import subprocess
from swayipc import Swayipc
from warehouse import get_base
Logs = "/tmp/sway_boot.log"
def apply_safe_config(sway):
try:
sway.cmd("default_border none")
sway.cmd("default_floating_border none")
sway.cmd("floating_modifier Mod4")
sway.cmd("bindsym Mod4+Shift+grave reload")
sway.cmd("bindsym Mod4+Shift+escape exit")
sway.cmd("bindsym Mod4+q exec kitty")
sway.cmd("bindsym Mod4+c kill")
sway.cmd("exec notify-send 'Sway FUCKED!' 'Fallback active'")
sway.cmd('for_window [app_id="xpad"] floating enable')
except Exception:
print("truely fucked")
pass
def boot(base):
base = os.path.expanduser(base)
with open(Logs, "w") as f:
return subprocess.run(
["python3", os.path.join(base, "main/swayconfig.py")],
stdout=f,
stderr=f
).returncode
def main():
sway = Swayipc()
base = get_base()
if not base:
print("BASE_SWAY isnt defined correctly. This WILL cause problems with startup.")
return
rc = boot(base)
if rc != 0:
apply_safe_config(sway)
subprocess.Popen(["xpad", "-f", Logs])
if __name__ == "__main__":
main()
+5 -5
View File
@@ -8,6 +8,7 @@ import base64
from datetime import datetime
from pathlib import Path
from warehouse import Media_flag, rand12
from swayipc import Swayipc
Recordings = Path.home() / "records"
Tmp = tempfile.gettempdir()
@@ -35,17 +36,16 @@ def find_focused_pid(node):
return None
def force_kill():
tree = json.loads(subprocess.check_output(
["swaymsg", "-t", "get_tree"],
text=True
))
sway = Swayipc()
tree = sway.tree()
pid = find_focused_pid(tree)
if not pid:
return
os.kill(pid, 9)
def is_recording():
return subprocess.run(
["pgrep", "-x", "wf-recorder"],
+81 -63
View File
@@ -1,12 +1,12 @@
import os
import time
import json
import socket
import struct
import subprocess
import urllib.request
from datetime import datetime
from pathlib import Path
from warehouse import Vpn_cache, Media_flag
import pulsectl
import psutil
from warehouse import Vpn_cache, Media_flag, http_get
class Cached:
def __init__(self, ttl):
@@ -25,105 +25,122 @@ class Cached:
return self.value
def http_get(url, timeout=2):
try:
with urllib.request.urlopen(url, timeout=timeout) as r:
return r.read().decode().strip()
except Exception:
return ""
class StatusBar:
def __init__(self):
self.cpu = Cached(5)
self.bat = Cached(5)
self.vpn = Cached(60)
self.ram = Cached(5)
self.bat = Cached(1)
self.vpn = Cached(1)
self.rec = Cached(1)
def run(self, cmd):
return subprocess.run(cmd, capture_output=True, text=True).stdout.strip()
def get_volume(self):
return self.run(["pamixer", "--get-volume-human"])
with pulsectl.Pulse("statusbar") as pulse:
sink = pulse.get_sink_by_name(
pulse.server_info().default_sink_name
)
volume = sink.volume.value_flat * 100
if sink.mute:
return "Muted"
return f"{volume:.0f}%"
def get_ram(self):
out = self.run(["free", "-m"]).splitlines()
mem = next((l for l in out if l.startswith("Mem:")), "")
parts = mem.split()
if len(parts) < 7:
return "?"
total = int(parts[1])
used = int(parts[2])
return f"{used//1000}GB/{total//1000}GB"
def compute():
mem = psutil.virtual_memory()
used = mem.total - mem.available
return f"{used // 1024**3}GB/{mem.total // 1024**3}GB"
return self.ram.get(compute)
def get_cpu(self):
def compute():
try:
out = self.run(["grep", "cpu ", "/proc/stat"])
p = out.split()
if len(p) < 8:
return "0.0%"
user, nice, system, idle = map(int, p[1:5])
total = user + nice + system + idle
busy = total - idle
return f"{(busy / total) * 100:.1f}%"
except Exception:
return "0.0%"
return f"{psutil.cpu_percent(interval=0.2):.1f}%"
return self.cpu.get(compute)
def get_battery(self):
def compute():
bat = Path("/sys/class/power_supply/BAT0")
if not bat.exists():
return ""
try:
cap = (bat / "capacity").read_text().strip()
status = (bat / "status").read_text().strip()
return f"{cap}% ({status})"
except Exception:
bat = psutil.sensors_battery()
if bat is None:
return ""
if bat.power_plugged:
status = "Charging"
else:
status = "Discharging"
return f"{bat.percent:.0f}% ({status})"
return self.bat.get(compute)
def get_vpn(self):
def compute():
if not self.run(["wg", "show", "interfaces"]):
try:
with open("/proc/net/dev") as f:
interfaces = [
line.split(":")[0].strip()
for line in f.readlines()[2:]
]
vpn = any(
iface.startswith(("wg", "tun", "tap", "ppp"))
for iface in interfaces
)
except Exception as e:
return ""
if not vpn:
if Vpn_cache.exists():
Vpn_cache.unlink()
return ""
country = ""
if Vpn_cache.exists():
country = Vpn_cache.read_text().strip()
if not country:
ip = http_get("https://ifconfig.me")
geo = http_get(f"https://iplookup.stab.ing/api/v1/lookup?ip={ip}")
try:
if Vpn_cache.exists():
country = Vpn_cache.read_text().strip()
if '"country"' in geo:
try:
country = geo.split('"country":"')[1].split('"')[0]
except Exception:
country = ""
if not country:
ip = http_get("https://ifconfig.me")
geo = http_get(
f"https://iplookup.stab.ing/api/v1/lookup?ip={ip}"
)
if country:
Vpn_cache.write_text(country)
country = json.loads(geo).get("country", "")
return f"VPN: {country or 'Unknown'}"
if country:
Vpn_cache.write_text(country)
except Exception as e:
print(e)
return f"VPN: {country or 'NAY!'}"
return self.vpn.get(compute)
def get_recording(self):
def compute():
return "RECORDING!" if self.run(["pgrep", "-x", "wf-recorder"]) else ""
for proc in psutil.process_iter(["name"]):
try:
if proc.info["name"] == "wf-recorder":
return "RECORDING!"
except (psutil.NoSuchProcess, psutil.AccessDenied):
pass
return ""
return self.rec.get(compute)
def get_time(self):
if Media_flag.exists():
return "0001-01-01 12:00 AM"
return self.run(["date", "+%Y-%m-%d %I:%M %p"])
return datetime.now().strftime("%Y-%m-%d %I:%M %p")
def render(self):
vol = self.get_volume()
@@ -138,14 +155,15 @@ class StatusBar:
if extra:
return f"CPU: {cpu} / RAM: {ram} / VOL: {vol} / {extra} / {t}"
return f"CPU: {cpu} / RAM: {ram} / VOL: {vol} / {t}"
def main():
bar = StatusBar()
while True:
print(bar.render(), flush=True)
time.sleep(0.1)
if __name__ == "__main__":
-164
View File
@@ -1,164 +0,0 @@
import os
import subprocess
import sys
from swayipc import Swayipc
import swayworkspace
from pathlib import Path
from warehouse import get_base
def run_sh(c):
subprocess.Popen(c, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def apply_ui_and_environment(sway):
base = os.path.expanduser(get_base())
sway.cmd("floating_modifier Mod4")
sway.cmd("default_border none")
sway.cmd("default_floating_border none")
sway.cmd("client.focused #ffffff #ffffff #ffffff #ffffff")
sway.cmd("client.focused_inactive #000000 #000000 #000000 #000000")
sway.cmd("client.unfocused #000000 #000000 #000000 #000000")
sway.cmd("client.urgent #ffffff #ffffff #ffffff #ffffff")
sway.cmd("client.placeholder #000000 #000000 #000000 #000000")
sway.cmd('for_window [app_id="xpad"] floating enable')
sway.cmd("exec_always gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'")
sway.cmd("exec_always gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'")
sway.cmd("exec_always gsettings set org.gnome.desktop.interface cursor-size 12")
sway.cmd("exec_always gsettings set org.gnome.desktop.interface font-name 'Noto Sans Mono 10'")
run_sh("wl-paste --watch cliphist store")
run_sh("/usr/lib/xdg-desktop-portal -r")
sway.cmd("setenv GTK_USE_PORTAL 0")
sway.cmd("setenv XDG_CURRENT_DESKTOP sway")
sway.cmd("setenv XDG_SESSION_TYPE wayland")
sway.cmd("setenv XDG_PORTAL_BACKEND wlroots")
run_sh(f"swaybg -i {base}/wallpaper/metrowaymaka.png -m fill")
run_sh("blueman-applet")
run_sh("kdeconnectd")
run_sh("/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1")
swayworkspace.SwaySome().init(1)
run_sh("dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP SWAYSOCK")
def bind_keys(sway):
base = get_base()
mod = "Mod4"
binding_actions = {}
script_path = os.path.abspath(__file__)
def assign_key(key_combo):
def decorator(func):
result = func()
sway.cmd(f"bindsym {key_combo} {result}")
return func
return decorator
@assign_key(f"{mod}+h")
def focus_left(): return "focus left"
@assign_key(f"{mod}+j")
def focus_down(): return "focus down"
@assign_key(f"{mod}+k")
def focus_up(): return "focus up"
@assign_key(f"{mod}+l")
def focus_right(): return "focus right"
@assign_key(f"{mod}+Shift+h")
def move_left(): return "move left"
@assign_key(f"{mod}+Shift+j")
def move_down(): return "move down"
@assign_key(f"{mod}+Shift+k")
def move_up(): return "move up"
@assign_key(f"{mod}+Shift+l")
def move_right(): return "move right"
@assign_key(f"{mod}+bracketleft")
def workspace_prev(): return "workspace prev"
@assign_key(f"{mod}+bracketright")
def workspace_next(): return "workspace next"
@assign_key(f"{mod}+Q")
def open_terminal(): return "exec kitty"
@assign_key(f"{mod}+c")
def kill_window(): return "kill"
@assign_key(f"{mod}+Shift+s")
def take_screenshot(): return f"exec python3 {base}/main/moves.py screenshot --out ~/screenshots/"
@assign_key(f"{mod}+Shift+escape")
def exit_sway(): return "exit"
@assign_key(f"{mod}+Up")
def volume_up(): return "exec pamixer --increase 5"
@assign_key(f"{mod}+Down")
def volume_down(): return "exec pamixer --decrease 5"
@assign_key(f"{mod}+Shift+grave")
def reload_sway(): return "reload"
@assign_key(f"{mod}+Shift+f")
def record_screen(): return f"exec python3 {base}/main/moves.py record --fullscreen"
@assign_key(f"{mod}+r")
def open_menu(): return "exec wofi --show drun --width 400 --height 500 --layer overlay --location 1"
@assign_key(f"{mod}+o")
def open_menu(): return "exec cliphist list | wofi -S dmenu --width 400 --height 500 --layer overlay --location 3 | cliphist decode | wl-copy"
@assign_key("Ctrl+Shift+Alt+Mod4+L")
def open_linkedin(): return "exec flatpak run io.github.ungoogled_software.ungoogled_chromium https://www.linkedin.com"
@assign_key(f"{mod}+Shift+c")
def force_kill(): return f"exec python3 {base}/main/moves.py kill"
@assign_key(f"{mod}+n")
def open_notes(): return "exec xpad"
@assign_key(f"{mod}+v")
def toggle_floating(): return "floating toggle"
@assign_key("XF86AudioPlay")
def media_play(): return "exec playerctl play-pause"
@assign_key("XF86AudioPause")
def media_pause(): return "exec playerctl play-pause"
for i in range(1, 11):
num = 0 if i == 10 else i
sway.cmd(f"bindsym {mod}+{num} exec python3 {base}/main/swayworkspace.py focus {i}")
sway.cmd(f"bindsym {mod}+Shift+{num} exec python3 {base}/main/swayworkspace.py move {i}")
return binding_actions
def build_bar(sway):
base = os.path.expanduser(get_base())
sway.cmd("bar bar-main position top")
sway.cmd(f"bar bar-main status_command python3 {base}/main/sway_status.py")
sway.cmd("bar bar-main font pango:Noto Sans Mono 10")
sway.cmd("bar bar-main mode dock")
sway.cmd("bar bar-main colors background #000000")
sway.cmd("bar bar-main colors statusline #ffffff")
sway.cmd("bar bar-main colors separator #ffffff")
sway.cmd("bar bar-main colors focused_workspace #000000 #ffffff #000000")
sway.cmd("bar bar-main colors active_workspace #000000 #ffffff #000000")
sway.cmd("bar bar-main colors inactive_workspace #000000 #000000 #ffffff")
sway.cmd("bar bar-main colors urgent_workspace #ffffff #ffffff #ffffff")
if __name__ == "__main__":
sway = Swayipc()
apply_ui_and_environment(sway)
bind_keys(sway)
build_bar(sway)
+4
View File
@@ -85,6 +85,10 @@ class Swayipc:
Output(name=o["name"], focused=o.get("focused", False), active=o.get("active", False))
for o in data if o.get("active", False)
]
def tree(self):
self._send(4, "")
return json.loads(self._read())
def workspaces(self):
self._send(1, "")
+2
View File
@@ -74,6 +74,8 @@ def main():
sway.focus_abs(n)
elif cmd == "move-abs":
sway.move_abs(n)
elif cmd == "init":
sway.init(n)
else:
print(f"Unknown command: {cmd}", file=sys.stderr)
sys.exit(1)
+6 -6
View File
@@ -1,14 +1,14 @@
# 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
import base64
import urllib.request
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]
return base64.urlsafe_b64encode(os.urandom(9)).decode()[:12]
def http_get(url, timeout=2):
with urllib.request.urlopen(url, timeout=timeout) as r:
return r.read().decode().strip()