diff options
author | dx <aryadevchavali1@gmail.com> | 2020-06-06 19:31:36 +0100 |
---|---|---|
committer | dx <aryadevchavali1@gmail.com> | 2020-06-06 19:31:36 +0100 |
commit | 45b80e8e67a2ea724d6f7317428cccf7ea9db395 (patch) | |
tree | 0b599e9ccff39ed8a276673787607c7a7c4b7df3 | |
parent | 852d280157a749a88e7e3826eda81b1ae080bf1d (diff) | |
download | dotfiles-45b80e8e67a2ea724d6f7317428cccf7ea9db395.tar.gz dotfiles-45b80e8e67a2ea724d6f7317428cccf7ea9db395.tar.bz2 dotfiles-45b80e8e67a2ea724d6f7317428cccf7ea9db395.zip |
~set_bar -> scripts/status/*
Decomposed the set_bar monolith script into seperate 'block' scripts
-rwxr-xr-x | Scripts/.local/scripts/refresh_bar | 4 | ||||
-rwxr-xr-x | Scripts/.local/scripts/set_bar | 85 | ||||
-rwxr-xr-x | Scripts/.local/scripts/status/battery | 25 | ||||
-rwxr-xr-x | Scripts/.local/scripts/status/connection | 9 | ||||
-rwxr-xr-x | Scripts/.local/scripts/status/datetime | 2 | ||||
-rwxr-xr-x | Scripts/.local/scripts/status/music | 10 | ||||
-rwxr-xr-x | Scripts/.local/scripts/status/volume | 21 |
7 files changed, 67 insertions, 89 deletions
diff --git a/Scripts/.local/scripts/refresh_bar b/Scripts/.local/scripts/refresh_bar deleted file mode 100755 index 6491ecc..0000000 --- a/Scripts/.local/scripts/refresh_bar +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -killall set_bar; -$HOME/.local/scripts/set_bar; diff --git a/Scripts/.local/scripts/set_bar b/Scripts/.local/scripts/set_bar deleted file mode 100755 index d13ab3e..0000000 --- a/Scripts/.local/scripts/set_bar +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -delimiter=' | ' - -timedate() { - echo $(date +'%a %F %R') -} - -battery() { - capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break - status=$(cat /sys/class/power_supply/BAT0/status) - - if [[ $status == "Charging" ]] - then - status="" - else - if [[ $capacity -ge 75 ]] - then - status="" - elif [[ $capacity -ge 50 ]] - then - status="" - elif [[ $capacity -ge 25 ]] - then - status="" - elif [[ $capacity -ge 10 ]] - then - status="" - else - status="" - fi - fi - echo "$status $capacity%" -} - -volume() { - sinks="$(pactl list sinks)" - vol="$(echo "$sinks" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")" - - if [[ $vol -gt 50 ]] - then - icon="" - elif [[ $vol -gt 10 ]] - then - icon="" - else - icon="" - fi - - echo "$icon $vol%" -} - -ram() { - echo $(vmstat -s -a -S M | grep 'used memory' | grep -Po "\d+")M -} - -disk() { - echo $(df | grep /dev/sda2 | awk '{print $5}') -} - -mpd() { - name=$(mpc -f '%title%' | head -1) - if [[ $name == "MPD error: Connection refused\n" ]] - then - name="MPD offline" - else - name="Playing: $name" - fi - echo $name -} - -connections() { - internet=$(nmcli g | sed -n 2p | awk '{print $1}') - if [[ $internet == "connected" ]] - then - echo "Connected" - else - echo "Not connected" - fi -} - -while true; do - xsetroot -name "$(mpd) $delimiter Meme level at $(disk) $delimiter $(ram) $delimiter $(connections) $delimiter $(volume) $delimiter $(battery) $delimiter $(timedate)" - sleep 30s; -done diff --git a/Scripts/.local/scripts/status/battery b/Scripts/.local/scripts/status/battery new file mode 100755 index 0000000..7680ac5 --- /dev/null +++ b/Scripts/.local/scripts/status/battery @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break +status=$(cat /sys/class/power_supply/BAT0/status) + +if [[ $status == "Charging" ]] +then + status="" +else + if [[ $capacity -ge 75 ]] + then + status="" + elif [[ $capacity -ge 50 ]] + then + status="" + elif [[ $capacity -ge 25 ]] + then + status="" + elif [[ $capacity -ge 10 ]] + then + status="" + else + status="" + fi +fi +echo "$status $capacity%" diff --git a/Scripts/.local/scripts/status/connection b/Scripts/.local/scripts/status/connection new file mode 100755 index 0000000..139fea0 --- /dev/null +++ b/Scripts/.local/scripts/status/connection @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +internet=$(nmcli g | sed -n 2p | awk '{print $1}') +if [[ $internet == "connected" ]] +then + echo "Connected" +else + echo "Not connected" +fi diff --git a/Scripts/.local/scripts/status/datetime b/Scripts/.local/scripts/status/datetime new file mode 100755 index 0000000..39f1c06 --- /dev/null +++ b/Scripts/.local/scripts/status/datetime @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo $(date +'%a %F %R') diff --git a/Scripts/.local/scripts/status/music b/Scripts/.local/scripts/status/music new file mode 100755 index 0000000..262dc81 --- /dev/null +++ b/Scripts/.local/scripts/status/music @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +name="$(mpc -f '%title%' | head -1)" +offline="$(echo $name | grep -E 'volume:|MPD')" +if [[ $offline ]] +then + name="MPD off" +else + name="Playing: $name" +fi +echo $name diff --git a/Scripts/.local/scripts/status/volume b/Scripts/.local/scripts/status/volume new file mode 100755 index 0000000..c3de64c --- /dev/null +++ b/Scripts/.local/scripts/status/volume @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +sinks="$(pactl list sinks)" +vol="$(echo "$sinks" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")" +mpc_vol="$($HOME/.local/scripts/mpc_volume)" + +if [[ $vol -gt 50 ]] +then + icon="" +elif [[ $vol -gt 10 ]] +then + icon="" +else + icon="" +fi + +if [[ $mpc_vol == "n/a" ]] +then + echo "$icon $vol%" +else + echo "$icon $vol% $mpc_vol%" +fi |