Use custom status bar in sway.
[Dotty.git] / sway / .config / sway / scripts / status.sh
1 # The Sway configuration file in ~/.config/sway/config calls this script.
2 # You should see changes to the status bar after saving this script.
3 # If not, do "killall swaybar" and $mod+Shift+c to reload the configuration.
5 # Change this according to your device
6 ################
7 # Variables
8 ################
10 # Keyboard input name
11 keyboard_input_name="1:1:AT_Translated_Set_2_keyboard"
13 # Date and time
14 date_and_week=$(date "+%Y/%m/%d (w%-V)")
15 current_time=$(date "+%H:%M")
17 #############
18 # Commands
19 #############
21 # Battery or charger
22 battery_charge=$(upower --show-info $(upower --enumerate | grep 'BAT') | egrep "percentage" | awk '{print $2}')
23 battery_status=$(upower --show-info $(upower --enumerate | grep 'BAT') | egrep "state" | awk '{print $2}')
25 # Audio and multimedia
26 audio_volume=$(pamixer --sink `pactl list sinks short | grep RUNNING | awk '{print $1}'` --get-volume)
27 audio_is_muted=$(pamixer --sink `pactl list sinks short | grep RUNNING | awk '{print $1}'` --get-mute)
28 media_artist=$(playerctl metadata artist)
29 media_song=$(playerctl metadata title)
30 player_status=$(playerctl status)
32 # Network
33 network=$(ip route get 1.1.1.1 | grep -Po '(?<=dev\s)\w+' | cut -f1 -d ' ')
34 # interface_easyname grabs the "old" interface name before systemd renamed it
35 interface_easyname=$(dmesg | grep $network | grep renamed | awk 'NF>1{print $NF}')
36 ping=$(ping -c 1 www.google.es | tail -1| awk '{print $4}' | cut -d '/' -f 2 | cut -d '.' -f 1)
38 # Others
39 language=$(swaymsg -r -t get_inputs | awk '/1:1:AT_Translated_Set_2_keyboard/;/xkb_active_layout_name/' | grep -A1 '\b1:1:AT_Translated_Set_2_keyboard\b' | grep "xkb_active_layout_name" | awk -F '"' '{print $4}')
40 loadavg_5min=$(cat /proc/loadavg | awk -F ' ' '{print $2}')
42 # Removed weather because we are requesting it too many times to have a proper
43 # refresh on the bar
44 #weather=$(curl -Ss 'https://wttr.in/Pontevedra?0&T&Q&format=1')
46 if [ $battery_status = "discharging" ];
47 then
48     battery_pluggedin='⚠'
49 else
50     battery_pluggedin='⚡'
51 fi
53 if ! [ $network ]
54 then
55    network_active="⛔"
56 else
57    network_active="⇆"
58 fi
60 if [ $player_status = "Playing" ]
61 then
62     song_status='▶'
63 elif [ $player_status = "Paused" ]
64 then
65     song_status='⏸'
66 else
67     song_status='⏹'
68 fi
70 if [ $audio_is_muted = "true" ]
71 then
72     audio_active='🔇'
73 else
74     audio_active='🔊'
75 fi
77 # Emojis and characters for the status bar
78 # 💎 💻 💡 🔌 ⚡ 📁 \|
79 echo "🎧 $song_status $media_artist - $media_song | ⌨ $language | $network_active $interface_easyname ($ping ms) | 🏋 $loadavg_5min | $audio_active $audio_volume% | $battery_pluggedin $battery_charge | $date_and_week 🕘 $current_time"
81 #echo $uptime_formatted ↑ $linux_version $battery_pluggedin $battery_charge 🕘 $date_formatted