old
#DATE=$(date "+ %a-%b-%d-%Y %I:%M %S%p")
#date=$(date "+%I:%M%p")
#bstat=$(head -c 1 /sys/class/power_supply/BAT0/status)
#bper=$(cat /sys/class/power_supply/BAT0/capacity)
#vol=$( wpctl get-volume @DEFAULT_AUDIO_SINK@ | cut -d : -f 2)
#vol=${vol##*0.}%
#wifi="$(awk '/^\s*w/ { print "wifi", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
#kblay=$(swaymsg -t get_inputs | grep -m1 'xkb_active_layout_name' | awk -F '"' '{print $4}'| head -c 3)
#bness="$(brightnessctl get)"
#max="$(brightnessctl max)"
#bperc="$((bness*100/max))"
#echo $kblay $bperc $vol $bstat$bper% $date
json bar
-----------------------------
#!/bin/sh
bg_bar_color="#282A36"
separator() {
echo -n "{"
echo -n "\"full_text\"\"\":," # CTRL+Ue0b2
echo -n "\"separator\":false,"
echo -n "\"separator_block_width\":0,"
echo -n "\"border\":\"$bg_bar_color\","
echo -n "\"border_left\":0,"
echo -n "\"border_right\":0,"
echo -n "\"border_top\":2,"
echo -n "\"border_bottom\":2,"
echo -n "\"color\":\"$1\","
echo -n "\"background\":\"$2\""
echo -n "}"
}
common() {
echo -n "\"border\": \"$bg_bar_color\","
echo -n "\"separator\":false,"
echo -n "\"separator_block_width\":0,"
echo -n "\"border_top\":2,"
echo -n "\"border_bottom\":2,"
echo -n "\"border_left\":0,"
echo -n "\"border_right\":0"
}
battery0() {
if [ -f /sys/class/power_supply/BAT0/uevent ]; then
local bg="#D69E2E"
1
bg_separator_previous=$bg
prct=$(cat /sys/class/power_supply/BAT0/capacity)
charging=$(cat /sys/class/power_supply/BAT0/status)
icon=""
if [ "$charging" == "Charging" ]; then
icon=""
fi
echo -n ",{"
echo -n "\"name\":\"battery0\","
echo -n "\"full_text\":\" ${icon} ${prct}% \","
echo -n "\"color\":\"#000000\","
echo -n "\"background\":\"$bg\","
common
echo -n "},"
else
bg_separator_previous="#E0E0E0"
fi
}
mydate() {
local bg="#E0E0E0"
separator $bg "#546E7A"
echo -n ",{"
echo -n "\"name\":\"id_time\","
echo -n "\"full_text\":\" $(date "+%a %d/%m %H:%M") \","
echo -n "\"color\":\"#000000\","
echo -n "\"background\":\"$bg\","
common
echo -n "},"
}
volume() {
local bg="#673AB7"
separator $bg $bg_separator_previous
vol=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | cut -d : -f 2)
echo -n ",{"
echo -n "\"name\":\"id_volume\","
if [ $vol -le 0 ]; then
echo -n "\"full_text\":\" ${vol}% \","
else
echo -n "\"full_text\":\" ${vol}% \","
fi
echo -n "\"background\":\"$bg\","
common
echo -n "},"
separator $bg_bar_color $bg
}
logout() {
echo -n ",{"
echo -n "\"name\":\"id_logout\","
echo -n "\"full_text\":\" \""
echo -n "}"
}
# Send the header so that i3bar knows we want to use JSON:
echo '{ "version": 1 , "click_events":true,"cont_signal": 18,"stop_signal": 19}'
# Begin the endless array.
echo '['
# We send an empty first array of blocks to make the loop simpler:
echo '[]'
# launched in a background process
while :;
do
echo -n ",["
mydate
battery0
volume
logout
echo "]"
sleep 10
done
# click events
while read line;
do
echo $line > /tmp/tmp.txt
# on click, we get from STDIN :
{"name":"id_time","button":1,"modifiers":["Mod2"],"x":2982,"y":9,"relative_x":67,"relative_y":9,"width":95,"height":22}
# DATE click
if [[ $line == *"name"*"id_time"* ]]; then
foot /home/kai/.config/sway/click_time.sh &
fi
# VOLUME
elif [[ $line == *"name"*"id_volume"* ]]; then
foot alsamixer &
elif [[ $line == *"name"*"id_logout"* ]]; then
swaynag -t warning -m 'Log out ?' -b 'yes' 'i3-msg exit' > /dev/null &
fi
done
---------------------------------
for alsa
vol=$(amixer get Master | sed -En 's/.*\[([0-9]+)%\].*/\1/p')
for debian pipewire
vol=$(pulsemixer --get-volume | cut -d ' ' -f 1)
https://github.com/i3/i3/blob/next/contrib/trivial-bar-script.sh
https://en.jeffprod.com/blog/2020/create-your-own-i3-sway-status-bar/
https://github.com/Tazeg/i3status/blob/master/i3status/mybar.sh
Comments
Post a Comment