diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-15 20:16:50 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-15 20:16:50 +0200 |
| commit | 818acc5e752efeabaea46b6c5e60cb5bcbb7412b (patch) | |
| tree | 98db970558b811cede2da7467b182b055e40748c /status | |
| parent | 706e50ace71471192d304f873ad058a638285a9a (diff) | |
| parent | a75c732b88bd27e351368b1a7b0c111df5488be1 (diff) | |
| download | scripts-818acc5e752efeabaea46b6c5e60cb5bcbb7412b.tar.gz scripts-818acc5e752efeabaea46b6c5e60cb5bcbb7412b.zip | |
Merge branch 'master' of tronto.net:scripts
Diffstat (limited to '')
| -rwxr-xr-x | status | 48 | ||||
| -rwxr-xr-x | status-openbsd | 20 | ||||
| -rwxr-xr-x | status-void | 41 |
3 files changed, 71 insertions, 38 deletions
| @@ -1,41 +1,13 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # Prints some status info to stdout. Includes: | 3 | # Calls one of the system-specific status scripts to display |
| 4 | # - date and time | 4 | # a line of text with some status information (battery, date...) |
| 5 | # - battery | ||
| 6 | # - wifi (requires nmcli) | ||
| 7 | # - past notifications (requires notify) | ||
| 8 | 5 | ||
| 9 | # Usage: status [separator] | 6 | case "$(uname)" in |
| 10 | 7 | OpenBSD) | |
| 11 | sep=${1:-" | "} | 8 | status-openbsd |
| 12 | 9 | ;; | |
| 13 | time=$(date +"%H:%M") | 10 | *) |
| 14 | date=$(date +"%d %B %Y, %A") | 11 | status-void |
| 15 | 12 | ;; | |
| 16 | if [ "$(pulsemixer --get-mute)" -eq 1 ]; then | 13 | esac |
| 17 | volume="Audio muted" | ||
| 18 | else | ||
| 19 | volume="Volume: $(pulsemixer --get-volume | awk '{print $1}')%" | ||
| 20 | fi | ||
| 21 | |||
| 22 | bat="/sys/class/power_supply/BAT0" | ||
| 23 | if [ -d $bat ]; then | ||
| 24 | battery="Battery: $(cat $bat/capacity)% $(cat $bat/status)" | ||
| 25 | else | ||
| 26 | battery="No battery" | ||
| 27 | fi | ||
| 28 | |||
| 29 | # NetworkManager has a dreadful command line interface | ||
| 30 | # It makes cry every time | ||
| 31 | # pls help | ||
| 32 | nwline="$(nmcli device status | head -n 2 | tail -n 1)" | ||
| 33 | nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')" | ||
| 34 | network="Network: $nwclean" | ||
| 35 | |||
| 36 | noticount=$(notify show | wc -l) | ||
| 37 | |||
| 38 | printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time" | ||
| 39 | [ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)" | ||
| 40 | [ "$noticount" -gt "1" ] && printf '%s' "${sep}Unread items: $noticount" | ||
| 41 | printf '\n' | ||
diff --git a/status-openbsd b/status-openbsd new file mode 100755 index 0000000..1f88b50 --- /dev/null +++ b/status-openbsd | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Prints some status info to stdout. Includes: | ||
| 4 | # - date and time | ||
| 5 | # - battery | ||
| 6 | # - wifi (requires ifconfig on OpenBSD) | ||
| 7 | |||
| 8 | # Usage: status [separator] | ||
| 9 | |||
| 10 | sep=${1:-" | "} | ||
| 11 | |||
| 12 | time=$(date +"%H:%M") | ||
| 13 | date=$(date +"%d %B %Y") | ||
| 14 | battery="$(apm | grep -o '[^ ]*%')" | ||
| 15 | network="$(ifconfig athn0 | grep status | sed 's/.*status: //')" | ||
| 16 | if [ "$network" = "active" ]; then | ||
| 17 | network="$(ifconfig athn0 | grep nwid | sed 's/.*nwid //;s/ chan.*//')" | ||
| 18 | fi | ||
| 19 | |||
| 20 | echo "$network$sep$battery$sep$date$sep$time" | ||
diff --git a/status-void b/status-void new file mode 100755 index 0000000..fcc4c28 --- /dev/null +++ b/status-void | |||
| @@ -0,0 +1,41 @@ | |||
| 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 +"%d %B %Y, %A") | ||
| 15 | |||
| 16 | if [ "$(pulsemixer --get-mute)" -eq 1 ]; then | ||
| 17 | volume="Audio muted" | ||
| 18 | else | ||
| 19 | volume="Volume: $(pulsemixer --get-volume | awk '{print $1}')%" | ||
| 20 | fi | ||
| 21 | |||
| 22 | bat="/sys/class/power_supply/BAT0" | ||
| 23 | if [ -d $bat ]; then | ||
| 24 | battery="Battery: $(cat $bat/capacity)% $(cat $bat/status)" | ||
| 25 | else | ||
| 26 | battery="No battery" | ||
| 27 | fi | ||
| 28 | |||
| 29 | # NetworkManager has a dreadful command line interface | ||
| 30 | # It makes cry every time | ||
| 31 | # pls help | ||
| 32 | nwline="$(nmcli device status | head -n 2 | tail -n 1)" | ||
| 33 | nwclean="$(echo "$nwline" | sed 's/ *$//' | sed 's/.* //')" | ||
| 34 | network="Network: $nwclean" | ||
| 35 | |||
| 36 | noticount=$(notify show | wc -l) | ||
| 37 | |||
| 38 | printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time" | ||
| 39 | [ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)" | ||
| 40 | [ "$noticount" -gt "1" ] && printf '%s' "${sep}Unread items: $noticount" | ||
| 41 | printf '\n' | ||
