From 8a0153027c4758a6ce6b5e4f9736eaccfddce7f0 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 23 Aug 2024 11:04:38 -0400 Subject: [PATCH] dwm: Add bar script --- specializations/dwm.nix | 50 +++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/specializations/dwm.nix b/specializations/dwm.nix index b54e36ae..6fe55a6e 100644 --- a/specializations/dwm.nix +++ b/specializations/dwm.nix @@ -10,6 +10,8 @@ let ; osu-backgrounds = pkgs.callPackage ../packages/osu-backgrounds.nix { }; + + barScript = "dwm/bar.fish"; in { home-manager.sharedModules = singleton { @@ -37,14 +39,8 @@ in xrdb -merge ~/.Xresources xset r rate 300 50 feh --bg-fill "$(fish -c 'random choice (fd . ${osu-backgrounds}/2024-07-15-Aerial-Antics-Art-Contest-All-Entries --follow -e jpg -e png)')" & - - while true; do - xsetroot -name "$(date +"%F %R")" - sleep 1m - done & - + ~/.config/${barScript} & picom --daemon - fcitx5 & while true; do @@ -54,6 +50,46 @@ in }; }; + xdg.configFile = { + ${barScript} = { + executable = true; + text = # fish + '' + #!/usr/bin/env fish + + function get_icon + if test "$argv" -gt 90 + echo " " + else if test "$argv" -gt 60 + echo " " + else if test "$argv" -gt 30 + echo " " + else if test "$argv" -gt 10 + echo " " + else + echo " " + end + end + + function update_bar + set VOLUME "音量:$(math "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) * 100")%" + set TIME "$(date '+%x(%a)%R')" + set capacity "$(cat /sys/class/power_supply/BAT0/capacity)" + + set BATTERY "$(get_icon $capacity)$capacity%" + + xsetroot -name "$VOLUME・$BATTERY・$TIME" + end + + while true + update_bar + + sleep 10s + end + ''; + }; + }; + services = { picom = rec { enable = true;