Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 1 | (defwidget bar [] |
| 2 | (centerbox :orientation "h" |
| 3 | :class "bar" |
| 4 | (workspaces) |
| 5 | (music) |
| 6 | (sidestuff))) |
| 7 | |
| 8 | (defwidget sidestuff [] |
| 9 | (box :class "sidestuff" :orientation "h" :space-evenly false :halign "end" |
| 10 | (metric :label "đ" |
| 11 | :value volume |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 12 | :onchange "nix run nixpkgs#pamixer -- --set-volume {}") |
| 13 | (radio) |
| 14 | (sysinfo) |
| 15 | time)) |
| 16 | |
| 17 | (defwidget radio [] |
| 18 | (box :class "radio" :orientation "h" :space-evenly false :halign "end" |
| 19 | (button :class bluetooth |
| 20 | :onclick { bluetooth == "inactive" ? "bluetoothctl power on" : "bluetoothctl power off"} |
| 21 | "ī") |
| 22 | (button :class wifi |
| 23 | :onclick { wifi == "disabled" ? "nmcli radio wifi on" : "nmcli radio wifi off"} |
| 24 | "đ") |
| 25 | ) |
| 26 | ) |
| 27 | |
| 28 | (defwidget sysinfo [] |
| 29 | (box :class "sysinfo" |
| 30 | ; (metric :label { battery_status == "Normal" ? "đ" : "đĒĢ" } |
| 31 | ; :value battery_cap |
| 32 | ; :onchange "") |
| 33 | (metric :label "đ" |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 34 | :value {EWW_RAM.used_mem_perc} |
| 35 | :onchange "") |
| 36 | (metric :label "đž" |
| 37 | :value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)} |
| 38 | :onchange "") |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 39 | (metric :label "đ" |
| 40 | :value cpu_usage_percent |
| 41 | :onchange "") |
| 42 | ) |
| 43 | ) |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 44 | |
| 45 | (defwidget workspaces [] |
| 46 | (box :class "workspaces" |
| 47 | :orientation "h" |
| 48 | :space-evenly true |
| 49 | :halign "start" |
| 50 | :spacing 10 |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 51 | (button :onclick "hyprctl dispatch workspace 1" 1) |
| 52 | (button :onclick "hyprctl dispatch workspace 2" 2) |
| 53 | (button :onclick "hyprctl dispatch workspace 3" 3) |
| 54 | (button :onclick "hyprctl dispatch workspace 4" 4) |
| 55 | (button :onclick "hyprctl dispatch workspace 5" 5) |
| 56 | (button :onclick "hyprctl dispatch workspace 6" 6) |
| 57 | (button :onclick "hyprctl dispatch workspace 7" 7) |
| 58 | (button :onclick "hyprctl dispatch workspace 8" 8) |
| 59 | (button :onclick "hyprctl dispatch workspace 9" 9) |
| 60 | (button :onclick "hyprctl dispatch workspace 0" 0) |
| 61 | )) |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 62 | |
| 63 | (defwidget music [] |
| 64 | (box :class "music" |
| 65 | :orientation "h" |
| 66 | :space-evenly false |
| 67 | :halign "center" |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 68 | :onclick "" |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 69 | {music != "" ? "đĩ${music}" : ""})) |
| 70 | |
| 71 | |
| 72 | (defwidget metric [label value onchange] |
| 73 | (box :orientation "h" |
| 74 | :class "metric" |
| 75 | :space-evenly false |
| 76 | (box :class "label" label) |
| 77 | (scale :min 0 |
| 78 | :max 101 |
| 79 | :active {onchange != ""} |
| 80 | :value value |
| 81 | :onchange onchange))) |
| 82 | |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 83 | (deflisten music :initial "" |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 84 | "nix run nixpkgs#playerctl -- --follow metadata --format '{{ title }}' || true") |
| 85 | |
| 86 | (defpoll bluetooth :interval "1s" |
| 87 | "rfkill -o TYPE,SOFT list -n | grep bluetooth | sed -E 's/bluetooth\s+//g'") |
| 88 | |
| 89 | (defpoll wifi :interval "1s" |
| 90 | "rfkill -o TYPE,SOFT list -n | grep wlan | sed -E 's/wlan\s+//g'") |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 91 | |
| 92 | (defpoll volume :interval "1s" |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 93 | "nix run nixpkgs#pamixer -- --get-volume") |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 94 | |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 95 | (defpoll battery_cap :interval "5m" |
| 96 | "cat /sys/class/power_supply/BAT*/capacity" |
| 97 | ) |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 98 | |
Skyler Grey | 4e23089 | 2024-02-13 22:58:46 +0000 | [diff] [blame] | 99 | (defpoll battery_status :interval "1s" |
| 100 | "cat /sys/class/power_supply/BAT*/status" |
| 101 | ) |
| 102 | |
| 103 | (defpoll cpu_usage_percent :interval "5s" |
| 104 | "bash scripts/cpu_usage" |
| 105 | ) |
| 106 | |
| 107 | (defpoll time :interval "1s" |
| 108 | "date '+%H:%M:%S %b %d, %Y'") |
| 109 | |
| 110 | (defwindow bar-primary |
Skyler Grey | a0da6b2 | 2024-02-11 22:53:41 +0000 | [diff] [blame] | 111 | :monitor 0 |
| 112 | :windowtype "dock" |
| 113 | :geometry (geometry :x "0%" |
| 114 | :y "0%" |
| 115 | :width "100%" |
| 116 | :height "10px" |
| 117 | :anchor "top center") |
| 118 | :exclusive true |
| 119 | (bar)) |