Compare commits

...

5 commits

17 changed files with 113 additions and 95 deletions

View file

@ -16,7 +16,7 @@
(label :text " " :class "space")) (label :text " " :class "space"))
(deflisten workspaces :initial "[]" "~/.config/eww/scripts/get-workspaces") (deflisten workspaces :initial "[]" "~/.config/eww/scripts/get-workspaces.sh")
(defwidget workspaces [monitor ?all] (defwidget workspaces [monitor ?all]
(box :space-evenly false :class "workspaces" (box :space-evenly false :class "workspaces"
(for workspace in workspaces (for workspace in workspaces
@ -24,20 +24,20 @@
(label :text {workspace.name}))))) (label :text {workspace.name})))))
(deflisten window :initial "..." "~/.config/eww/scripts/get-window-title") (deflisten window :initial "..." "~/.config/eww/scripts/get-window-title.sh")
(defwidget window [] (defwidget window []
(box (box
(label :text {window ?: ""}))) (label :text {window ?: ""})))
(deflisten audio :initial "--" "~/.config/eww/scripts/get-audio") (deflisten audio :initial "--" "~/.config/eww/scripts/get-audio.sh")
(defwidget volume [] (defwidget volume []
(eventbox :cursor {audio.muted ? "pointer" : "row-resize"} :onscroll "~/.config/eww/scripts/adjust-volume {}" :onclick "pactl set-sink-mute @DEFAULT_SINK@ toggle" (eventbox :cursor {audio.muted ? "pointer" : "row-resize"} :onscroll "~/.config/eww/scripts/adjust-volume.sh {}" :onclick "pactl set-sink-mute @DEFAULT_SINK@ toggle"
(label_value :text {audio.muted ? "󰝟" : "󰕾"} :value "${audio.volume}%" :value_class {audio.muted ? "muted" : ""}))) (label_value :text {audio.muted ? "󰝟" : "󰕾"} :value "${audio.volume}%" :value_class {audio.muted ? "muted" : ""})))
(defwidget audio_source [] (defwidget audio_source []
(eventbox :onclick "~/.config/eww/scripts/swap-audio-source" :cursor "pointer" (eventbox :onclick "~/.config/eww/scripts/swap-audio-source.sh" :cursor "pointer"
(label :text {audio.source} :class "audio-info"))) (label :text {audio.source} :class "audio-info")))
(defwidget audio_sink [] (defwidget audio_sink []
(eventbox :onclick "~/.config/eww/scripts/swap-audio-sink" :cursor "pointer" (eventbox :onclick "~/.config/eww/scripts/swap-audio-sink.sh" :cursor "pointer"
(label :text {audio.sink} :class "audio-info"))) (label :text {audio.sink} :class "audio-info")))
@ -53,22 +53,16 @@
(label_circle :text "" :value {EWW_CPU.avg})) (label_circle :text "" :value {EWW_CPU.avg}))
(defvar combined_interface true) (defvar combined_interface true)
(deflisten interfaces :initial '{}' "~/.config/eww/scripts/network-statistics-shell 5") (deflisten interfaces :initial '{}' "~/.config/eww/scripts/network-statistics-shell.sh 5")
(defwidget network_speed [label interface] (defwidget network_speed [label interface]
(eventbox :onclick "${EWW_CMD} update combined_interface=${!combined_interface}" :cursor {interfaces?.[interface]?.up ? "pointer" : ""} (eventbox :onclick "${EWW_CMD} update combined_interface=${!combined_interface}" :cursor {interfaces?.[interface]?.up ? "pointer" : ""}
(tooltip (tooltip
(graph :value {interfaces?.[interface]?.combined_raw ?: 0} :thickness 2 :time-range 60000 :dynamic true :line-style "round" :width 60 :height 20) (graph :value {interfaces?.[interface]?.combined_raw ?: 0} :thickness 2 :time-range 60000 :dynamic true :line-style "round" :width 60 :height 20)
(label_value :text label :value {(interfaces?.[interface]?.up ?: false) ? (combined_interface ? interfaces?.[interface]?.combined : "󰶡${interfaces?.[interface]?.rx} 󰶣${interfaces?.[interface]?.tx}") : "dc"} :value_class {(interfaces?.[interface]?.up ?: false) ? "" : "disabled"})))) (label_value :text label :value {(interfaces?.[interface]?.up ?: false) ? (combined_interface ? interfaces?.[interface]?.combined : "󰶡${interfaces?.[interface]?.rx} 󰶣${interfaces?.[interface]?.tx}") : "dc"} :value_class {(interfaces?.[interface]?.up ?: false) ? "" : "disabled"}))))
(defwidget eth [] (defwidget eth [interface]
(network_speed :label "󰈀" :interface "enp6s0")) (network_speed :label "󰈀" :interface {interface}))
(defwidget wlan [] (defwidget wlan [interface]
(network_speed :label "" (network_speed :label "" :interface {interface}))
{% if host.name == "chonk" %}
:interface "wlo1"
{% else %}
:interface "wlp1s0"
{% endif %}
))
(defwidget date [] (defwidget date []
(tooltip (tooltip
@ -120,18 +114,21 @@
;(defwidget colour_selector [] ;(defwidget colour_selector []
;(clicker :text "" :command "uwsm-app -- hyprpicker -a")) ;(clicker :text "" :command "uwsm-app -- hyprpicker -a"))
(defwidget wallpaper [] (defwidget wallpaper []
(clicker :text "󰸉" :command "~/.config/eww/scripts/wallpaper-shell")) (clicker :text "󰸉" :command "~/.config/eww/scripts/wallpaper-shell.sh"))
(defwidget sunset [] (defwidget sunset []
(clicker :text "" :command "python -OO ~/scripts/sunset.py")) (clicker :text "" :command "python -OO ~/scripts/sunset.py"))
(defvar docked false)
(defwidget docked []
(clicker :text {docked ? "󰌢" : "󰛧"} :command "${EWW_CMD} update docked=${!docked} ; hyprctl keyword monitor eDP-1,${docked ? "" : "disabled"}"))
(defpoll brightness :interval 60 "~/.config/eww/scripts/backlight get") (defpoll brightness :interval 60 "~/.config/eww/scripts/backlight.sh get")
(defwidget brightness [] (defwidget brightness []
(eventbox :onscroll "~/.config/eww/scripts/backlight {}" :cursor "row-resize" (eventbox :onscroll "~/.config/eww/scripts/backlight.sh {}" :cursor "row-resize"
(label_value :text "󰌵" :value "${brightness}%"))) (label_value :text "󰌵" :value "${brightness}%")))
(defpoll battery :interval 30 "~/.config/eww/scripts/get-battery") (defpoll battery :interval 30 "~/.config/eww/scripts/get-battery.sh")
(defwidget battery [] (defwidget battery []
(label_value :text {battery.charging ? "󰂄" : battery.icon} :value "${battery.charge}%" :value_class {battery.charge < 30 ? "alert" : ""})) (label_value :text {battery.charging ? "󰂄" : battery.icon} :value "${battery.charge}%" :value_class {battery.charge < 30 ? "alert" : ""}))
@ -159,11 +156,13 @@
(box :class "right" :orientation "h" :space-evenly false :halign "end" (box :class "right" :orientation "h" :space-evenly false :halign "end"
(volume)(sep) (volume)(sep)
(audio_source)(space) (audio_source)(space)
(audio_sink)))) (audio_sink)(sep)
(datetime))))
(defwidget right_bar [] (defwidget right_bar []
(centerbox :class "bar" :orientation "h" (centerbox :class "bar" :orientation "h"
(box :class "left" :orientation "h" :space-evenly false :halign "begin" (box :class "left" :orientation "h" :space-evenly false :halign "begin"
(workspaces :monitor "DP-1")) (workspaces :monitor "DP-1")(sep :class "no-left-pad")
(window))
(systray :pack_direction "ltr" :icon-size 20) (systray :pack_direction "ltr" :icon-size 20)
(box :class "right" :orientation "h" :space-evenly false :halign "end" (box :class "right" :orientation "h" :space-evenly false :halign "end"
(gametime)(space) (gametime)(space)
@ -174,29 +173,58 @@
(mountpoint :label "󰋊" :mount "/home/mbradley/hdd")(sep) (mountpoint :label "󰋊" :mount "/home/mbradley/hdd")(sep)
(ram)(space) (ram)(space)
(cpu)(sep) (cpu)(sep)
(eth)(sep) ;(wlan :interface "wlo1")(space)
(eth :interface "enp6s0")(sep)
(datetime)(sep) (datetime)(sep)
(power)))) (power))))
(defwidget laptop_bar [] (defwidget laptop_bar []
(centerbox :class "bar" :orientation "h" (centerbox :class "bar" :orientation "h"
(box :class "left" :orientation "h" :space-evenly false :halign "begin" (box :class "left" :orientation "h" :space-evenly false :halign "begin"
(workspaces :monitor "eDP-1" :all true)(sep) (workspaces :monitor "eDP-1" :all true)(sep :class "no-left-pad")
(window)) (window))
(systray :pack_direction "ltr" :icon-size 20) (systray :pack_direction "ltr" :icon-size 20)
(box :class "right" :orientation "h" :space-evenly false :halign "end" (box :class "right" :orientation "h" :space-evenly false :halign "end"
(weather)(sep) (weather)(sep)
;(colour_selector)(space) ;(colour_selector)(space)
(sunset)(space) (sunset)(space)
(wallpaper)(sep) (wallpaper)(space)
(docked)(sep)
(ram)(space) (ram)(space)
(cpu)(sep) (cpu)(sep)
(wlan)(space) (wlan :interface "wlp1s0")(space)
(battery)(sep) (battery)(sep)
(brightness)(space) (brightness)(space)
(volume)(sep) (volume)(sep)
(datetime)(sep) (datetime)(sep)
(power)))) (power))))
(defwidget laptop_left_bar []
(centerbox :class "bar" :orientation "h"
(box :class "left" :orientation "h" :space-evenly false :halign "begin"
(workspaces :monitor "DP-3" :all true)(sep :class "no-left-pad")
(window))
(box)
(box :class "right" :orientation "h" :space-evenly false :halign "end"
(volume)(sep)
(datetime))))
(defwidget laptop_right_bar []
(centerbox :class "bar" :orientation "h"
(box :class "left" :orientation "h" :space-evenly false :halign "begin"
(workspaces :monitor "DP-2" :all true)(sep :class "no-left-pad")
(window))
(systray :pack_direction "ltr" :icon-size 20)
(box :class "right" :orientation "h" :space-evenly false :halign "end"
(weather)(sep)
(sunset)(space)
(wallpaper)(space)
(docked)(sep)
(ram)(space)
(cpu)(sep)
(eth :interface "enp193s0f3u2")(space)
(battery)(sep)
(volume)(sep)
(datetime)(sep)
(power))))
(defwindow left (defwindow left
@ -224,7 +252,7 @@
(right_bar)) (right_bar))
(defwindow laptop (defwindow laptop
:monitor 0 :monitor "eDP-1"
:geometry (geometry :x "0px" :geometry (geometry :x "0px"
:y "4px" :y "4px"
:width "1912px" :width "1912px"
@ -235,7 +263,7 @@
:focusable false :focusable false
(laptop_bar)) (laptop_bar))
(defwindow laptop_left (defwindow laptop_left
:monitor 1 :monitor "DP-3"
:geometry (geometry :x "0px" :geometry (geometry :x "0px"
:y "4px" :y "4px"
:width "2552px" :width "2552px"
@ -244,9 +272,9 @@
:stacking "fg" :stacking "fg"
:exclusive true :exclusive true
:focusable false :focusable false
(laptop_bar)) (laptop_left_bar))
(defwindow laptop_right (defwindow laptop_right
:monitor 2 :monitor "DP-2"
:geometry (geometry :x "0px" :geometry (geometry :x "0px"
:y "4px" :y "4px"
:width "2552px" :width "2552px"
@ -255,4 +283,4 @@
:stacking "fg" :stacking "fg"
:exclusive true :exclusive true
:focusable false :focusable false
(laptop_bar)) (laptop_right_bar))

View file

@ -1,12 +0,0 @@
#!/bin/env sh
DELTA="1%"
case "$1" in
"up") pactl set-sink-volume @DEFAULT_SINK@ +"$DELTA"
;;
"down") pactl set-sink-volume @DEFAULT_SINK@ -"$DELTA"
;;
*) exit 1
;;
esac

9
eww/scripts/adjust-volume.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/env sh
DELTA="1%"
case "$1" in
up) pactl set-sink-volume @DEFAULT_SINK@ +"$DELTA";;
down) pactl set-sink-volume @DEFAULT_SINK@ -"$DELTA";;
*) exit 1;;
esac

View file

@ -1,14 +0,0 @@
#!/bin/env sh
DELTA="1%"
case "$1" in
up) brightnessctl -m -c backlight set +"$DELTA"
;;
down) brightnessctl -m -c backlight set "$DELTA"-
;;
get) brightnessctl -m -c backlight get
;;
*) echo "Unrecognized command"; exit 1
;;
esac

10
eww/scripts/backlight.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/env sh
DELTA="1%"
case "$1" in
up) brightnessctl -m -c backlight set +"$DELTA";;
down) brightnessctl -m -c backlight set "$DELTA"-;;
get) brightnessctl -m -c backlight get;;
*) echo "Unrecognized command"; exit 1;;
esac

View file

@ -11,14 +11,9 @@ get_or_default() {
} }
case "$1" in case "$1" in
"headphones") echo "$DEFAULT_HEADPHONES" # TODO: Figure out generic regex string to match headphones headphones) echo "$DEFAULT_HEADPHONES";; # TODO: Figure out generic regex string to match headphones
;; speakers) get_or_default 'sinks' 'HiFi__Headphones__sink' "$DEFAULT_SPEAKERS";;
"speakers") get_or_default 'sinks' 'HiFi__Headphones__sink' "$DEFAULT_SPEAKERS" headphone_mic) echo "$DEFAULT_HEADPHONE_MIC";; # TODO: Figure out generic regex string to match headphone mic
;; blue_mic) get_or_default 'sources' 'Generic_Blue_Microphones[a-zA-Z0-9_.\\-]+\\.analog-stereo$' "$DEFAULT_BLUE_MIC";;
"headphone_mic") echo "$DEFAULT_HEADPHONE_MIC" # TODO: Figure out generic regex string to match headphone mic *) echo "Device name '$1' not recognized"; exit 1;;
;;
"blue_mic") get_or_default 'sources' 'Generic_Blue_Microphones[a-zA-Z0-9_.\\-]+\\.analog-stereo$' "$DEFAULT_BLUE_MIC"
;;
*) echo "Device name '$1' not recognized"; exit 1
;;
esac esac

View file

@ -1,4 +1,4 @@
#!/bin/env sh #!/bin/env sh
# EWW doesn't seem to like listening to Python scripts directly, but this wrapper seems to work fine # EWW doesn't seem to like listening to Python scripts directly, but this wrapper seems to work fine
"$(dirname "$0")"/network-statistics $@ python -OO "$(dirname "$0")"/network_statistics.py "$@"

View file

@ -9,14 +9,14 @@ from typing import Literal, NoReturn
def get_interfaces() -> list[Path]: def get_interfaces() -> list[Path]:
return list(Path("/sys/class/net/").glob("*")) return list(Path("/sys/class/net/").iterdir())
class TransferredBytes: class TransferredBytes:
def __init__(self, interface: Path, statistic: Literal["tx"] | Literal["rx"]) -> None: def __init__(self, interface: Path, statistic: Literal["tx"] | Literal["rx"]) -> None:
self._statistic = interface / f"statistics/{statistic}_bytes" self._statistic: Path = interface / f"statistics/{statistic}_bytes"
self._current = int(self._statistic.read_text()) self._current: int = int(self._statistic.read_text())
self._previous = self._current self._previous: int = self._current
def update(self) -> None: def update(self) -> None:
self._previous = self._current self._previous = self._current
@ -28,17 +28,19 @@ class TransferredBytes:
class Status: class Status:
def __init__(self, interface: Path) -> None: def __init__(self, interface: Path) -> None:
self._statistic = interface / "operstate" self._statistic: Path = interface / "operstate"
def up(self) -> bool: def up(self) -> bool:
return self._statistic.read_text().strip() == "up" return self._statistic.read_text().strip() == "up"
def format_4_significant_digits(num: float) -> str: def format_4_significant_digits(num: float) -> str:
if num < 100: assert num >= 1.0, "Doesn't properly handle numbers below 1"
return f"{num:#.3g}" if num < 999:
return f"{num:04.3g}"
if num < 1000: if num < 1000:
return f" {num:.3g}" # Above doesn't nicely handle the special case in [999.5 1000)
return "0999"
return f"{num:.4g}" return f"{num:.4g}"
@ -56,10 +58,10 @@ def format_bytes(num: float) -> str:
class Interface: class Interface:
def __init__(self, location: Path) -> None: def __init__(self, location: Path) -> None:
self._location = location self._location: Path = location
self._tx = TransferredBytes(location, "tx") self._tx: TransferredBytes = TransferredBytes(location, "tx")
self._rx = TransferredBytes(location, "rx") self._rx: TransferredBytes = TransferredBytes(location, "rx")
self._status = Status(location) self._status: Status = Status(location)
@property @property
def name(self) -> str: def name(self) -> str:
@ -84,7 +86,7 @@ class Interface:
class Statistics: class Statistics:
def __init__(self) -> None: def __init__(self) -> None:
self._interfaces = [Interface(location) for location in get_interfaces()] self._interfaces: list[Interface] = [Interface(location) for location in get_interfaces()]
def update(self) -> None: def update(self) -> None:
for interface in self._interfaces: for interface in self._interfaces:

View file

@ -5,7 +5,7 @@ monitor = eDP-1, 2880x1920@120, 0x0, 1.5
decoration { decoration {
blur { blur {
enabled = true enabled = true
size = 5 size = 3
passes = 1 passes = 1
} }
@ -37,11 +37,11 @@ gestures {
workspace = 1, monitor:DP-3, default:true workspace = 1, monitor:DP-3, default:true
workspace = 2, monitor:DP-2, default:true workspace = 2, monitor:DP-2, default:true
workspace = 3, monitor:eDP-1, default:true workspace = 3, monitor:DP-3
workspace = 4, monitor:DP-3 workspace = 4, monitor:DP-2
workspace = 5, monitor:DP-2 workspace = 5, monitor:DP-3
workspace = 6, monitor:eDP-1 workspace = 6, monitor:DP-2
workspace = 7, monitor:DP-3 workspace = 7, monitor:DP-3
workspace = 8, monitor:DP-2 workspace = 8, monitor:DP-2
workspace = 9, monitor:eDP-1 workspace = 9, monitor:DP-3
workspace = 10, monitor:DP-3 workspace = 10

View file

@ -19,18 +19,18 @@ listener {
} }
listener { listener {
timeout = 270 timeout = 480
on-timeout = loginctl lock-session
}
listener {
timeout = 300
on-timeout = hyprctl dispatch dpms off on-timeout = hyprctl dispatch dpms off
on-resume = hyprctl dispatch dpms on on-resume = hyprctl dispatch dpms on
} }
listener { listener {
timeout = 600 timeout = 600
on-timeout = loginctl lock-session
}
listener {
timeout = 1200
on-timeout = systemctl suspend on-timeout = systemctl suspend
} }
{% endif %} {% endif %}