comparison 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
comparison
equal deleted inserted replaced
2:a2c891f7b914 3:84d6074a5566
1 { writeShellApplication, coreutils, gawk, xsetroot, wireplumber, playerctl }:
2
3 writeShellApplication {
4 name = "dwmbar";
5 runtimeInputs = [ coreutils gawk xsetroot wireplumber playerctl ];
6 text = ''
7 while true; do
8 # volume
9 vol_raw=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
10 vol=$(echo "$vol_raw" | awk '{print int($2*100)}')
11 if [[ "$vol_raw" == *MUTED* ]]; then
12 vol_icon=$'\uf026'
13 else
14 vol_icon=$'\uf028'
15 fi
16
17 music_icon=$'\uf001'
18 cal_icon=$'\uf073'
19
20 # mpris
21 music=""
22 if [ "$(playerctl status 2>/dev/null)" = "Playing" ]; then
23 track=$(playerctl metadata --format '{{artist}} - {{title}}' 2>/dev/null)
24 music="$music_icon ''${track:0:50} "
25 fi
26
27 # battery
28 cap=$(cat /sys/class/power_supply/BAT0/capacity)
29 status=$(cat /sys/class/power_supply/BAT0/status)
30 if [ "$status" = "Charging" ]; then
31 bat_icon=$'\uf0e7'
32 elif [ "$cap" -ge 88 ]; then
33 bat_icon=$'\uf240'
34 elif [ "$cap" -ge 63 ]; then
35 bat_icon=$'\uf241'
36 elif [ "$cap" -ge 38 ]; then
37 bat_icon=$'\uf242'
38 elif [ "$cap" -ge 13 ]; then
39 bat_icon=$'\uf243'
40 else
41 bat_icon=$'\uf244'
42 fi
43
44 # date
45 now=$(date '+%m/%d/%Y %I:%M %p')
46
47 xsetroot -name " $music$vol_icon $vol% $bat_icon $cap% $cal_icon $now "
48 sleep 2
49 done
50 '';
51 }