diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-06 08:30:49 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-06 08:30:49 +0200 |
| commit | 60052659b98832c78c902e4f27ecee2663d8e913 (patch) | |
| tree | 9efc1388569c43456557aa1975b4bec99bf06c94 /scripts/status-linux | |
| parent | 10e16c2fb2266bb2b46ec7ea64d721de0c29a0d9 (diff) | |
| download | config-60052659b98832c78c902e4f27ecee2663d8e913.tar.gz config-60052659b98832c78c902e4f27ecee2663d8e913.zip | |
Added scripts
Diffstat (limited to 'scripts/status-linux')
| -rwxr-xr-x | scripts/status-linux | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/status-linux b/scripts/status-linux new file mode 100755 index 0000000..a2061d1 --- /dev/null +++ b/scripts/status-linux | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Prints some status info to stdout. Includes: | ||
| 4 | # - date and time | ||
| 5 | # - battery | ||
| 6 | # - wifi (requires nmcli) | ||
| 7 | # - past notifications (requires notify) | ||
| 8 | |||
| 9 | # Usage: status [separator] | ||
| 10 | |||
| 11 | sep=${1:-" | "} | ||
| 12 | |||
| 13 | time=$(date +"%H:%M") | ||
| 14 | date=$(date +"%a %d %b") | ||
| 15 | |||
| 16 | if [ "$(pulsemixer --get-mute)" -eq 1 ]; then | ||
| 17 | volume="Muted" | ||
| 18 | else | ||
| 19 | volume="Vol $(pulsemixer --get-volume | awk '{print $1}')%" | ||
| 20 | fi | ||
| 21 | |||
| 22 | bat="/sys/class/power_supply/BAT0" | ||
| 23 | if [ -d $bat ]; then | ||
| 24 | charge_status="$(cat $bat/status | awk '{print substr ($0, 0, 2)}')" | ||
| 25 | battery="Bat $(cat $bat/capacity)% $charge_status" | ||
| 26 | else | ||
| 27 | battery="No battery" | ||
| 28 | fi | ||
| 29 | |||
| 30 | # NetworkManager has a dreadful command line interface | ||
| 31 | # It makes cry every time | ||
| 32 | # pls help | ||
| 33 | #nwline="$(nmcli device status | head -n 2 | tail -n 1)" | ||
| 34 | #nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')" | ||
| 35 | #network="Network: $nwclean" | ||
| 36 | |||
| 37 | # Thank you iwctl for saving us from this dreadful existence | ||
| 38 | network="$(iwctl station wlan0 show | grep 'Connected network' | awk '{print $3}')" | ||
| 39 | if [ "$(cat /sys/class/net/eth0/carrier)" = 1 ]; then | ||
| 40 | if [ -z "$network" ]; then | ||
| 41 | network="eth" | ||
| 42 | else | ||
| 43 | network="eth & $network" | ||
| 44 | fi | ||
| 45 | fi | ||
| 46 | |||
| 47 | noticount=$(notify show | wc -l) | ||
| 48 | |||
| 49 | printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time" | ||
| 50 | [ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)" | ||
| 51 | [ "$noticount" -gt "1" ] && printf '%s' "${sep}[$noticount]" | ||
| 52 | printf '\n' | ||
