From 78d8ef68f69da82c0f3a1be81441c1fb79c3a96c Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Tue, 22 Oct 2024 15:16:55 -0600 Subject: [PATCH] Re-added volume keys to sway config --- .../eww/eww.yuck##hostname.gathering-storm | 26 ++++++ .../network.yuck##hostname.gathering-storm | 77 ++++++++++++++++++ .../network.py##hostname.gathering-storm | 81 +++++++++++++++++++ .config/sway/config | 4 + ...arrangement.conf##hostname.gathering-storm | 9 +++ ...0-gtk-theme.conf##hostname.gathering-storm | 3 + .../workspaces.json##hostname.gathering-storm | 76 +++++++++++++++++ .../bar-launch.conf##hostname.gathering-storm | 4 + 8 files changed, 280 insertions(+) create mode 100644 .config/eww/eww.yuck##hostname.gathering-storm create mode 100644 .config/eww/modules/network.yuck##hostname.gathering-storm create mode 100755 .config/eww/scripts/network.py##hostname.gathering-storm create mode 100644 .config/sway/display-arrangement.conf##hostname.gathering-storm create mode 100644 .config/sway/local-config.d/10-gtk-theme.conf##hostname.gathering-storm create mode 100644 .config/sway/workspaces.json##hostname.gathering-storm create mode 100644 .config/systemd/user/eww.service.d/bar-launch.conf##hostname.gathering-storm diff --git a/.config/eww/eww.yuck##hostname.gathering-storm b/.config/eww/eww.yuck##hostname.gathering-storm new file mode 100644 index 0000000..6f4e171 --- /dev/null +++ b/.config/eww/eww.yuck##hostname.gathering-storm @@ -0,0 +1,26 @@ +;; -*-lisp-*- Include modules +(include "./modules/workspaces.yuck") +(include "./modules/clock.yuck") +(include "./modules/system.yuck") +(include "./modules/network.yuck") +(include "./modules/volume.yuck") +(include "./modules/aggietime.yuck") +(include "./modules/timer.yuck") +(include "./modules/mpris.yuck") + +(defvar power--state "normal") + +(include "./windows.yuck") + +(defwindow builtinbar + :monitor 0 + :geometry (geometry :width "100%" + :height "36px" + :anchor "top center") + :exclusive true + :focusable false + :stacking "fg" + (centerbox :orientation "h" :class "bar root ${power--state == 'critical' ? 'reservepower' : ''}" + (rocinante-builtinbar--left) + (rocinante-builtinbar--center) + (rocinante-builtinbar--right))) diff --git a/.config/eww/modules/network.yuck##hostname.gathering-storm b/.config/eww/modules/network.yuck##hostname.gathering-storm new file mode 100644 index 0000000..dca9b60 --- /dev/null +++ b/.config/eww/modules/network.yuck##hostname.gathering-storm @@ -0,0 +1,77 @@ +;; -*-lisp-*- +(deflisten network--data + `~/.config/eww/scripts/network.py`) + +(defwidget network--wlan [device] + (box :orientation "h" + :halign "start" + :space-evenly false + :spacing 10 + (label :class "offline" + :visible {network--data["network"][device]["offline"]} + :text "offline") + (label :visible {network--data["network"][device]["connecting"]} + :class "highlight" + :text "connecting...") + (label :visible {network--data["network"][device]["online"] && !network--data.network[device].connecting} + :class "special" + :text "${network--data['wifi']['ssid']}") + (label :visible {!network--data.connection.internet && network--data.network[device].online} + :class "highlight" + :text "- no internet" + ))) + +(defwidget network--lan [device] + (box :orientation "h" + :halign "start" + :space-evenly false + :spacing 0 + (label :class "offline" + :visible {network--data["network"][device]["offline"]} + :text "offline") + (label :visible {network--data["network"][device]["connecting"]} + :class "highlight" + :text "connecting...") + (label :visible {network--data["network"][device]["online"] && !network--data.network[device].connecting} + :class "special" + :text "${network--data['network'][device]['ip4_addr']}/${network--data['network'][device]['ip4_prefix']}"))) + +(defwidget network--proxy-vpn [device ?required] + (box :orientation "h" + :halign "start" + :space-evenly false + :spacing 0 + :visible {network--data.connection.internet && (network--data["network"][device]["exists"] || required)} + (label :class "highlight" + :text "- insecure" + :visible {! network--data["network"][device]["exists"]}) + (label :class "green" + :text "- secured" + :visible {network--data["network"][device]["exists"]}))) + +(defwidget vpn-network [] + (box :orientation "v" + :halign "start" + :space-evenly false + :spacing 0 + (label :class "highlight" + :text "offline" + :visible {!network--data.connection.ezrinet}) + (label :class "green" + :text "connected" + :visible {network--data.connection.ezrinet}) + "personal network")) + +(defwidget network [] + (box :orientation "v" + :halign "start" + :space-evenly false + :spacing 0 + (box :orientation "h" + :halign "center" + :space-evenly false + :spacing 10 + (network--wlan :device "wlan0") + (network--proxy-vpn :device "wg-mullvad" :required {!network--data.trusted})) + "communications")) + diff --git a/.config/eww/scripts/network.py##hostname.gathering-storm b/.config/eww/scripts/network.py##hostname.gathering-storm new file mode 100755 index 0000000..742aa39 --- /dev/null +++ b/.config/eww/scripts/network.py##hostname.gathering-storm @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 + +import subprocess +import json +from time import sleep + +TRUSTED_NETWORKS = ['gayer people'] + +def wifi(): + ssid_cmd = subprocess.run(['iwgetid', '-r'], capture_output = True) + if ssid_cmd.returncode != 0: + return {"connected": False, "ssid": None} + ssid = ssid_cmd.stdout.decode('utf-8').strip() + ssid = ssid if len(ssid) <= 15 else f"{ssid[:14]}…" + return {"connected": True, "ssid": ssid} + +def netdev(device: str): + ip_cmd = subprocess.run(['ip', '-j', 'addr', 'show', device], capture_output = True) + if ip_cmd.returncode != 0: + return {"exists": False} + ip_data = json.loads(ip_cmd.stdout.decode('utf-8'))[0] + online = ip_data["operstate"] == "UP" + ip4_addr = "" + ip4_prefix_length = 24 + addr4_info = list(filter(lambda addr: addr.get("family") == "inet", ip_data["addr_info"])) + if len(addr4_info) >= 1: + ip4_addr = addr4_info[0]["local"] + ip4_prefix_length = addr4_info[0]["prefixlen"] + connecting = ip_data["operstate"] != "DOWN" and (ip4_addr == "" or not online) + return { + "exists": True, + "online": online, + "connecting": connecting, + "offline": not online and not connecting, + "ip4_addr": ip4_addr, + "ip4_prefix": ip4_prefix_length + } + +def trusted(ssid: str | None): + # Don't throw up an "INSECURE" alert when offline + if not ssid: + return True + return ssid in TRUSTED_NETWORKS + +def ping(host: str): + ping_cmd = subprocess.Popen(['/usr/bin/ping', '-c1', '-W2', host], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return ping_cmd + +counter = 0 +ezrinet_last = False +internet_last = False +ezrinet_ping = None +internet_ping = None + +while True: + if counter == 0: + ezrinet_ping = ping('10.242.3.1') + internet_ping = ping('1.1.1.1') + if ezrinet_ping.poll() is not None: + ezrinet_last = ezrinet_ping.returncode == 0 + if internet_ping.poll() is not None: + internet_last = internet_ping.returncode == 0 + wifi_data = wifi() + result = { + "wifi": wifi_data, + "network": { + "wlan0": netdev("wlan0"), + "ezrinet": netdev("ezrinet"), + "wg-mullvad": netdev("mullvad"), + }, + "connection": { + "ezrinet": ezrinet_last, + "internet": internet_last + }, + "trusted": trusted(wifi_data.get("ssid", None)) + } + print(json.dumps(result), flush=True) + counter += 1 + # Send pings every 10 seconds + counter %= 3 + sleep(1) diff --git a/.config/sway/config b/.config/sway/config index baf6bb9..4fc261f 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -192,6 +192,10 @@ bindsym --locked { XF86AudioPlay exec playerctl play-pause XF86AudioNext exec playerctl next XF86AudioPrev exec playerctl previous + + XF86AudioRaiseVolume exec pactl set-sink-volume @DEFUALT_SINK@ +5% + XF86AudioLowerVolume exec pactl set-sink-volume @DEFUALT_SINK@ -5% + XF86AudioMute exec pactl set-sink-mute @DEFUALT_SINK@ toggle } ## Screen Locking diff --git a/.config/sway/display-arrangement.conf##hostname.gathering-storm b/.config/sway/display-arrangement.conf##hostname.gathering-storm new file mode 100644 index 0000000..72c729e --- /dev/null +++ b/.config/sway/display-arrangement.conf##hostname.gathering-storm @@ -0,0 +1,9 @@ +### -*-conf-space-*- ### +# Gathering Storm Display Config # +### ### + +set $display eDP-1 + +output $display scale 1 pos 0 1080 +output $display color_profile icc /usr/share/color/icc/colord/BOE_CQ_______NE160QDM_NZ6.icm + diff --git a/.config/sway/local-config.d/10-gtk-theme.conf##hostname.gathering-storm b/.config/sway/local-config.d/10-gtk-theme.conf##hostname.gathering-storm new file mode 100644 index 0000000..472de82 --- /dev/null +++ b/.config/sway/local-config.d/10-gtk-theme.conf##hostname.gathering-storm @@ -0,0 +1,3 @@ +#-*-conf-space-*- + +exec_always gsettings set org.gnome.desktop.interface text-scaling-factor 1.25 diff --git a/.config/sway/workspaces.json##hostname.gathering-storm b/.config/sway/workspaces.json##hostname.gathering-storm new file mode 100644 index 0000000..ba2ca28 --- /dev/null +++ b/.config/sway/workspaces.json##hostname.gathering-storm @@ -0,0 +1,76 @@ +{ + "default_context": "personal", + "display_ordering": ["builtin"], + "display_layout": { + "builtin": "eDP-1" + }, + "contexts": { + "personal": { + "builtin": [ + { + "index": 1, + "name": "terminal", + "exec": "console", + "program_name": "console" + }, + { + "index": 2, + "name": "code", + "exec": "emacsclient", + "args": ["-nc"], + "program_name": "emacsclient" + }, + { + "index": 3, + "name": "internet", + "exec": "firefox", + "args": ["--new-window"], + "program_name": "firefox" + }, + { + "index": 4, + "name": "project", + "exec": "firefox", + "args": ["--new-window"], + "program_name": "firefox" + }, + { + "index": 5, + "name": "servers", + "exec": "virt-manager", + "program_name": "virt-manager" + }, + { + "index": 6, + "name": "steam", + "exec": "steam", + "program_name": "steam" + }, + { + "index": 7, + "name": "media", + "exec": "jellyfinmediaplayer", + "program_name": "jellyfinmediaplayer" + }, + { + "index": 8, + "name": "real-time comms", + "exec": "discord", + "program_name": "discord" + }, + { + "index": 9, + "name": "messages", + "exec": "thunderbird", + "program_name": "thunderbird" + }, + { + "index": 10, + "name": "config", + "exec": "pavucontrol", + "program_name": "pavucontrol" + } + ] + } + } +} diff --git a/.config/systemd/user/eww.service.d/bar-launch.conf##hostname.gathering-storm b/.config/systemd/user/eww.service.d/bar-launch.conf##hostname.gathering-storm new file mode 100644 index 0000000..f57e9d6 --- /dev/null +++ b/.config/systemd/user/eww.service.d/bar-launch.conf##hostname.gathering-storm @@ -0,0 +1,4 @@ +# -*-conf-unix-*- + +[Service] +ExecStartPost=eww open-many builtinbar