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
11 keyboard_input_name="1:1:AT_Translated_Set_2_keyboard"
14 date_and_week=$(date "+%Y/%m/%d (w%-V)")
15 current_time=$(date "+%H:%M")
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)
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)
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
44 #weather=$(curl -Ss 'https://wttr.in/Pontevedra?0&T&Q&format=1')
46 if [ $battery_status = "discharging" ];
60 if [ $player_status = "Playing" ]
63 elif [ $player_status = "Paused" ]
70 if [ $audio_is_muted = "true" ]
77 # Emojis and characters for the status bar
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