diff options
Diffstat (limited to 'herbstluftwm')
8 files changed, 165 insertions, 106 deletions
diff --git a/herbstluftwm/.config/herbstluftwm/panel_indicators.sh b/herbstluftwm/.config/herbstluftwm/panel_indicators.sh index 2a3d2e6..a65be74 100755 --- a/herbstluftwm/.config/herbstluftwm/panel_indicators.sh +++ b/herbstluftwm/.config/herbstluftwm/panel_indicators.sh | |||
| @@ -1,36 +1,17 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | 2 | ||
| 3 | icon_font="FontAwesome-10" | 3 | source "$HLWM_CONF_DIR/system_utils/all.sh" |
| 4 | |||
| 5 | export icon_font="FontAwesome-10" | ||
| 4 | 6 | ||
| 5 | battery_icon=("\uf244" "\uf243" "\uf242" "\uf241" "\uf240" "\uf1e6") | 7 | battery_icon=("\uf244" "\uf243" "\uf242" "\uf241" "\uf240" "\uf1e6") |
| 6 | network_icon=("\uf1eb" "\uf109") | 8 | network_icon=("\uf1eb" "\uf109") |
| 7 | music_icon="\uf001" | 9 | music_icon="\uf001" |
| 8 | volume_icon=("\uf026" "\uf027" "\uf028") | 10 | volume_icon=("\uf026" "\uf027" "\uf028") |
| 9 | 11 | ||
| 10 | music() | 12 | hlwm_indicator_music() |
| 11 | { | 13 | { |
| 12 | # Music | 14 | playing=$(hlwm_utils_music_playing) |
| 13 | mpd_status=$(mpc | sed -nr "s/^\[(.*)\].*$/\1/p") | ||
| 14 | if [ $mpd_status = "playing" ]; then | ||
| 15 | player_artist=$(mpc -f "%artist%" current) | ||
| 16 | player_title=$(mpc -f "%title%" current) | ||
| 17 | if [ -n "$player_artist" ]; then | ||
| 18 | playing="$player_artist - $player_title" | ||
| 19 | else | ||
| 20 | playing="$player_title" | ||
| 21 | fi | ||
| 22 | elif [ $(playerctl status) = "Playing" ]; then | ||
| 23 | player_artist=$(playerctl metadata artist) | ||
| 24 | player_title=$(playerctl metadata title) | ||
| 25 | if [ -n "$player_artist" ] && [ -n "$player_title" ]; then | ||
| 26 | playing="$player_artist - $player_title" | ||
| 27 | else | ||
| 28 | now_playing=$(playerctl metadata vlc:nowplaying) | ||
| 29 | playing="$now_playing" | ||
| 30 | fi | ||
| 31 | else | ||
| 32 | playing="" | ||
| 33 | fi | ||
| 34 | 15 | ||
| 35 | if [ -n "$playing" ]; then | 16 | if [ -n "$playing" ]; then |
| 36 | if [ "$current" != "$playing" ] ; then | 17 | if [ "$current" != "$playing" ] ; then |
| @@ -48,70 +29,39 @@ music() | |||
| 48 | fi | 29 | fi |
| 49 | } | 30 | } |
| 50 | 31 | ||
| 51 | volume() | 32 | hlwm_indicator_volume() |
| 52 | { | 33 | { |
| 53 | # Volume | 34 | # Volume |
| 54 | if pgrep pulseaudio >> /dev/null ; then | 35 | if pgrep pulseaudio >> /dev/null ; then |
| 55 | volumes=$(\ | 36 | volume=$(hlwm_utils_volume) |
| 56 | amixer get Master | \ | 37 | if [ -z "$volume" ] ; then |
| 57 | grep "Front Right: Playback"\ | 38 | volume_status="off" |
| 58 | ) | 39 | elif [ "$volume" -eq 0 ]; then |
| 59 | vol=$(\ | 40 | volume_status="%{F$HLWM_FG_ACOLOR}${volume_icon[0]} $volume%%{F-}" |
| 60 | echo $volumes | \ | 41 | elif [ "$volume" -lt 33 ]; then |
| 61 | sed "s/.*\[\([0-9]*\)%\].*/\1/"\ | 42 | volume_status="%{F$HLWM_FG_ACOLOR}${volume_icon[1]} $volume%%{F-}" |
| 62 | ) | ||
| 63 | if [ -z $vol ] ; then | ||
| 64 | vol_status="off" | ||
| 65 | elif [ $vol -eq 0 ]; then | ||
| 66 | vol_status="%{F$HLWM_FG_ACOLOR}${volume_icon[0]} $vol%%{F-}" | ||
| 67 | elif [ $vol -lt 33 ]; then | ||
| 68 | vol_status="%{F$HLWM_FG_ACOLOR}${volume_icon[1]} $vol%%{F-}" | ||
| 69 | else | 43 | else |
| 70 | vol_status="%{F$HLWM_FG_ACOLOR}${volume_icon[2]} $vol%%{F-}" | 44 | volume_status="%{F$HLWM_FG_ACOLOR}${volume_icon[2]} $volume%%{F-}" |
| 71 | fi | 45 | fi |
| 72 | echo -e "volume\t$vol_status" | 46 | echo -e "volume\t$volume_status" |
| 73 | else | 47 | else |
| 74 | echo -e "volume\toff" | 48 | echo -e "volume\toff" |
| 75 | fi | 49 | fi |
| 76 | } | 50 | } |
| 77 | 51 | ||
| 78 | network() | 52 | hlwm_indicator_network() |
| 79 | { | 53 | { |
| 80 | # Network | 54 | # Network |
| 81 | read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` | 55 | conn=$(hlwm_utils_active_network) |
| 82 | if iwconfig $int1 >/dev/null 2>&1; then | 56 | conn_type=$(echo "$conn" | cut -d: -f1) |
| 83 | wifi=$int1 | 57 | |
| 84 | eth=$int2 | 58 | if [ "$conn_type" = "wifi" ] ; then |
| 85 | else | 59 | ssid=$(echo "$conn" | cut -d: -f2) |
| 86 | wifi=$int2 | 60 | quality=$(echo "$conn" | cut -d: -f3) |
| 87 | eth=$int1 | 61 | net_status="${network_icon[0]} $ssid $quality%" |
| 88 | fi | 62 | elif [ "$conn_type" = "eth" ] ; then |
| 89 | 63 | name=$(echo "$conn" | cut -d: -f2) | |
| 90 | ip link show $eth | grep 'state UP' >/dev/null && int=$eth || int=$wifi | 64 | net_status="${network_icon[1]} $name" |
| 91 | |||
| 92 | if [ $int == $wifi ] ; then | ||
| 93 | iwconfig=$(iwconfig $int) | ||
| 94 | ssid=$( | ||
| 95 | echo $iwconfig | \ | ||
| 96 | sed "s/.*ESSID:\(\".*\"\).*/\1/" | \ | ||
| 97 | sed "s/.*\(off\/any\).*/\"\1\"/" | \ | ||
| 98 | sed "s/.*\"\(.*\)\".*/\1/" | ||
| 99 | ) | ||
| 100 | |||
| 101 | quality=$( \ | ||
| 102 | echo $iwconfig | \ | ||
| 103 | sed "s/^.*Link Quality=\([0-9]*\)\/\([0-9]*\) .*$/(\1*100)\/\2/" | \ | ||
| 104 | bc | ||
| 105 | ) | ||
| 106 | |||
| 107 | if [ $ssid == "off/any" ] ; then | ||
| 108 | net_status="off" | ||
| 109 | else | ||
| 110 | net_status="${network_icon[0]} $ssid $quality%" | ||
| 111 | fi | ||
| 112 | |||
| 113 | elif [ $int == $eth ] ; then | ||
| 114 | net_status="${network_icon[1]} Ethernet" | ||
| 115 | else | 65 | else |
| 116 | net_status="off" | 66 | net_status="off" |
| 117 | fi | 67 | fi |
| @@ -119,39 +69,50 @@ network() | |||
| 119 | echo -e "net\t$net_status" | 69 | echo -e "net\t$net_status" |
| 120 | } | 70 | } |
| 121 | 71 | ||
| 122 | battery() | 72 | hlwm_indicator_battery() |
| 123 | { | 73 | { |
| 124 | # Batteries | 74 | # Batteries |
| 125 | bat_info="off" | 75 | battery_info="" |
| 126 | for bat in $(find /sys/class/power_supply | grep BAT); do | 76 | while read -r battery; do |
| 127 | nr="${bat: -1}" | 77 | |
| 128 | bat_info="" | 78 | battery=($battery) |
| 129 | 79 | battery_nr=${battery[0]} | |
| 130 | bat_lvl=$(cat /sys/class/power_supply/BAT$nr/capacity) | 80 | battery_status=${battery[1]} |
| 131 | bat_state=$(cat /sys/class/power_supply/BAT$nr/status) | 81 | battery_level=${battery[2]} |
| 132 | 82 | ||
| 133 | if [ $bat_state == "Charging" ] ; then | 83 | if [ "$battery_status" = "Charging" ] ; then |
| 134 | bat_status="${battery_icon[5]}" | 84 | battery_status="${battery_icon[5]}" |
| 135 | elif [ $bat_lvl -lt 10 ] ; then | 85 | elif [ "$battery_level" -lt 10 ] ; then |
| 136 | bat_status="%{F$HLWM_ACCENT_ACOLOR}${battery_icon[0]}%{F-}" | 86 | battery_status="%{F$HLWM_ACCENT_ACOLOR}${battery_icon[0]}%{F-}" |
| 137 | elif [ $bat_lvl -lt 25 ] ; then | 87 | elif [ "$battery_level" -lt 25 ] ; then |
| 138 | bat_status="${battery_icon[1]}" | 88 | battery_status="${battery_icon[1]}" |
| 139 | elif [ $bat_lvl -lt 50 ] ; then | 89 | elif [ "$battery_level" -lt 50 ] ; then |
| 140 | bat_status="${battery_icon[2]}" | 90 | battery_status="${battery_icon[2]}" |
| 141 | elif [ $bat_lvl -lt 75 ] ; then | 91 | elif [ "$battery_level" -lt 75 ] ; then |
| 142 | bat_status="${battery_icon[3]}" | 92 | battery_status="${battery_icon[3]}" |
| 143 | else | 93 | else |
| 144 | bat_status="${battery_icon[4]}" | 94 | battery_status="${battery_icon[4]}" |
| 145 | fi | 95 | fi |
| 146 | 96 | ||
| 147 | bat_info+="$nr: $bat_status $bat_lvl%%{F-}" | 97 | battery_info+="$battery_nr: $battery_status $battery_level%%{F-}" |
| 148 | done | 98 | done < <(hlwm_utils_battery) |
| 149 | echo -e "battery\t$bat_info" | 99 | |
| 100 | if [ -z "$battery_info" ] ; then | ||
| 101 | echo -e "battery\toff" | ||
| 102 | else | ||
| 103 | echo -e "battery\t$battery_info" | ||
| 104 | fi | ||
| 150 | } | 105 | } |
| 151 | 106 | ||
| 152 | clock() | 107 | hlwm_indicator_clock() |
| 153 | { | 108 | { |
| 154 | echo -e $(date +$"date\t%{F$HLWM_FG_ACOLOR}%H:%M:%S %{F$HLWM_FG_ACOLOR}(%d-%m-%Y)%{F-}") | 1 | |
