diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-06-01 17:51:41 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-06-01 17:52:16 +0000 |
commit | 72f7908100684a223102d5c129af375aed5933ba (patch) | |
tree | 6975d55a4dd3aa5069dc40dec397bcf1817c72df /modules/workstation/windowing/sway | |
parent | 8a7da194cd10f90e038627ccb1c9b7c8dac42b29 (diff) | |
download | nixlib-72f7908100684a223102d5c129af375aed5933ba.tar nixlib-72f7908100684a223102d5c129af375aed5933ba.tar.gz nixlib-72f7908100684a223102d5c129af375aed5933ba.tar.bz2 nixlib-72f7908100684a223102d5c129af375aed5933ba.tar.lz nixlib-72f7908100684a223102d5c129af375aed5933ba.tar.xz nixlib-72f7908100684a223102d5c129af375aed5933ba.tar.zst nixlib-72f7908100684a223102d5c129af375aed5933ba.zip |
modules/sway: don't hardcode battery number
Diffstat (limited to 'modules/workstation/windowing/sway')
-rw-r--r-- | modules/workstation/windowing/sway/status_command.in | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/modules/workstation/windowing/sway/status_command.in b/modules/workstation/windowing/sway/status_command.in index 59537af22efa..b2cd2c792b28 100644 --- a/modules/workstation/windowing/sway/status_command.in +++ b/modules/workstation/windowing/sway/status_command.in @@ -2,26 +2,33 @@ loopwhilex +elglob bats /sys/class/power_supply/BAT* + # We need to capture the whole status line, and then echo it all at # once, to work around https://github.com/swaywm/sway/issues/3857. backtick -i -n line { foreground { - backtick -i -n status { cat /sys/class/power_supply/BAT0/status } - importas -i -u status status + forx bat { $bats } + importas -i -u bat bat - ifelse { test $status = Charging } - { printf "↑" } + foreground { + backtick -i -n status { cat ${bat}/status } + importas -i -u status status - if { test $status = Discharging } - printf "↓" - } + ifelse { test $status = Charging } + { printf "↑" } - foreground { - redirfd -r 0 /sys/class/power_supply/BAT0/capacity - tr -d "\n" - } + if { test $status = Discharging } + printf "↓" + } + + foreground { + redirfd -r 0 ${bat}/capacity + tr -d "\n" + } - foreground { printf "%% " } + foreground { printf "%% " } + } foreground { date "+%Y-%m-%d %H:%M:%S" } } |