Mercurial > nixos
diff modules/dwmbar.nix @ 3:84d6074a5566
Fix: forgot to hg add
| author | Yasuri <yasuri@charliesmp.net> |
|---|---|
| date | Sat, 03 Oct 2026 19:15:32 -0500 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/dwmbar.nix Sat Oct 03 19:15:32 2026 -0500 @@ -0,0 +1,51 @@ +{ writeShellApplication, coreutils, gawk, xsetroot, wireplumber, playerctl }: + +writeShellApplication { + name = "dwmbar"; + runtimeInputs = [ coreutils gawk xsetroot wireplumber playerctl ]; + text = '' + while true; do + # volume + vol_raw=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) + vol=$(echo "$vol_raw" | awk '{print int($2*100)}') + if [[ "$vol_raw" == *MUTED* ]]; then + vol_icon=$'\uf026' + else + vol_icon=$'\uf028' + fi + + music_icon=$'\uf001' + cal_icon=$'\uf073' + + # mpris + music="" + if [ "$(playerctl status 2>/dev/null)" = "Playing" ]; then + track=$(playerctl metadata --format '{{artist}} - {{title}}' 2>/dev/null) + music="$music_icon ''${track:0:50} " + fi + + # battery + cap=$(cat /sys/class/power_supply/BAT0/capacity) + status=$(cat /sys/class/power_supply/BAT0/status) + if [ "$status" = "Charging" ]; then + bat_icon=$'\uf0e7' + elif [ "$cap" -ge 88 ]; then + bat_icon=$'\uf240' + elif [ "$cap" -ge 63 ]; then + bat_icon=$'\uf241' + elif [ "$cap" -ge 38 ]; then + bat_icon=$'\uf242' + elif [ "$cap" -ge 13 ]; then + bat_icon=$'\uf243' + else + bat_icon=$'\uf244' + fi + + # date + now=$(date '+%m/%d/%Y %I:%M %p') + + xsetroot -name " $music$vol_icon $vol% $bat_icon $cap% $cal_icon $now " + sleep 2 + done + ''; +}
