소스 검색

Split status bar into separate files

Frans Bergman 5 년 전
부모
커밋
7a9aee9622
6개의 변경된 파일27개의 추가작업 그리고 11개의 파일을 삭제
  1. 13 11
      .scripts/dwm_status.sh
  2. 6 0
      .scripts/status/10-music.sh
  3. 2 0
      .scripts/status/20-volume.sh
  4. 2 0
      .scripts/status/30-mem.sh
  5. 2 0
      .scripts/status/40-temp.sh
  6. 2 0
      .scripts/status/99-date.sh

+ 13 - 11
.scripts/dwm_status.sh

@@ -1,15 +1,17 @@
 #!/bin/sh
 
+trap 'echo "Caught SIGUSR1"' USR1
+
 while true; do
-    if playerctl metadata; then
-        MUSIC="$(playerctl metadata artist) - $(playerctl metadata title)"
-    else
-        MUSIC="$(mpc current)"
-    fi
-    MEM="$(free -h | awk '(NR==2){ print $3 }')"
-    VOL="$(pulseaudio-ctl full-status | awk '{print $1 "%" ($2 == "yes" ? " (muted)" : "")}')"
-    TEMP="$(sensors | awk '/Package/{print $4}')"
-    DATE="$(date +"%F %T")"
-    xsetroot -name " $MUSIC | $VOL | $MEM | $TEMP | $DATE"
-    sleep 5
+    STATUS=""
+    for section in "$HOME"/.scripts/status/*.sh; do
+        if [ -z "$STATUS" ]; then
+            STATUS="$($section)"
+        else
+            STATUS="$STATUS | $($section)"
+        fi
+    done
+    xsetroot -name " $STATUS"
+    sleep 5 &
+    wait $!
 done

+ 6 - 0
.scripts/status/10-music.sh

@@ -0,0 +1,6 @@
+#!/bin/sh
+if playerctl metadata; then
+    echo "$(playerctl metadata artist) - $(playerctl metadata title)"
+else
+    mpc current
+fi

+ 2 - 0
.scripts/status/20-volume.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+pulseaudio-ctl full-status | awk '{print $1 "%" ($2 == "yes" ? " (muted)" : "")}'

+ 2 - 0
.scripts/status/30-mem.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+free -h | awk '(NR==2){ print $3 }'

+ 2 - 0
.scripts/status/40-temp.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+sensors | awk '/Package/{print $4}'

+ 2 - 0
.scripts/status/99-date.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+date +"%F %T"