Re-added volume keys to sway config

This commit is contained in:
Ezri Brimhall 2024-10-22 15:16:55 -06:00
parent 7bc36d299b
commit 78d8ef68f6
8 changed files with 280 additions and 0 deletions

View File

@ -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)))

View File

@ -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"))

View File

@ -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)

View File

@ -192,6 +192,10 @@ bindsym --locked {
XF86AudioPlay exec playerctl play-pause XF86AudioPlay exec playerctl play-pause
XF86AudioNext exec playerctl next XF86AudioNext exec playerctl next
XF86AudioPrev exec playerctl previous 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 ## Screen Locking

View File

@ -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

View File

@ -0,0 +1,3 @@
#-*-conf-space-*-
exec_always gsettings set org.gnome.desktop.interface text-scaling-factor 1.25

View File

@ -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"
}
]
}
}
}

View File

@ -0,0 +1,4 @@
# -*-conf-unix-*-
[Service]
ExecStartPost=eww open-many builtinbar