forked from mirrored-repos/iso-profiles
253 lines
7.1 KiB
Bash
Executable file
253 lines
7.1 KiB
Bash
Executable file
#! /bin/dash
|
||
#panel script for bspwm using i3 style workspace indicator
|
||
|
||
#set height and font if unset
|
||
|
||
if ! [ -f "$HOME/.limepanelrc" ]; then
|
||
cat > "$HOME"/.limepanelrc <<EOL
|
||
#ionicons
|
||
panel_height='25'
|
||
mainfont='Terminus:size=14:antialias=false'
|
||
iconfont="TerminessTTF Nerd Font:size=15:antialias=true"
|
||
thirdfont="TerminessTTF Nerd Font:size=16:antialias=true"
|
||
#thirdfont="Ionicons:size=16:antialias=false"
|
||
gap=$(awk -F"=" '/gap=/ {print $2}' ~/.config/bspwm/bspwmrc)
|
||
main_menu="rofimenu"
|
||
networkmenu="networkmenu.sh"
|
||
wifi_indicator=true
|
||
window_button="%{A:bspc node -c:} %{A}"
|
||
menu_icon=
|
||
charging_icon=
|
||
battery_full_icon=
|
||
battery_draining_icon=
|
||
battery_half_icon=
|
||
battery_low_icon=
|
||
time_icon=
|
||
wired_icon=
|
||
disconnected_icon=
|
||
#
|
||
muted_icon=
|
||
#
|
||
unmuted_icon=
|
||
tiling_icon=
|
||
monocle_icon=
|
||
title_length=60
|
||
COLOR_FOCUSED_DESKTOP_FG='#FF1ABB9B'
|
||
COLOR_FOCUSED_DESKTOP_BG="#FF292f34"
|
||
COLOR_DESKTOP_FG='#FFF6F9FF'
|
||
COLOR_DESKTOP_BG="#FF292f34"
|
||
DARKGREY="%{F#FF707880}"
|
||
RED="%{F#FFA54242}"
|
||
COLOR_TITLE="#FFdadde5"
|
||
update_interval=3
|
||
systemtray=0
|
||
EOL
|
||
fi
|
||
SP="%{O4}"
|
||
#SEPARATOR="$FC1 ▏$FC"
|
||
SEPARATOR="$SP${DARKGREY}%{R}%{O1}%{R}${FC}$SP"
|
||
. "$HOME"/.limepanelrc
|
||
|
||
# Kill any panel processes older than us, instead of bailing like the example
|
||
# does. That caused one too many panel-less boots for me.
|
||
|
||
while [ $(pgrep -cx simplepanel) -gt 1 ] ; do pkill -ox -9 limepanel ; done ;
|
||
while [ $(pgrep -cx lemonbar) -gt 0 ] ; do pkill -ox -9 lemonbar ; done ;
|
||
while [ $(pgrep -cx xtitle) -gt 0 ] ; do pkill -ox -9 xtitle ; done ;
|
||
while [ $(pgrep -cx bspc) -gt 0 ] ; do pkill -ox -9 bspc ; done ;
|
||
while [ $(pgrep -cx stalonetray) -gt 0 ] ; do pkill -ox -9 stalonetray ; done ;
|
||
|
||
|
||
trap '[ -e /tmp/panel-fifo1 ] && rm /tmp/panel-fifo1' INT TERM QUIT EXIT
|
||
|
||
|
||
logo="%{A:$main_menu:} $menu_icon %{A}"
|
||
is_wifi()
|
||
{
|
||
interface_up=$(ip link show | awk '/state UP/ {print substr($2, 1, length($2)-1)}')
|
||
iwconfig "$interface_up" >/dev/null 2>&1
|
||
}
|
||
sigStrength()
|
||
{
|
||
if ip link show | grep -q 'state UP';
|
||
then
|
||
if ! is_wifi;
|
||
then
|
||
echo %{F$COLOR_FOCUSED_DESKTOP_FG}$wired_icon
|
||
|
||
else
|
||
signalStrength=$(awk 'NR==3 {print $3}' /proc/net/wireless)
|
||
case "$signalStrength" in
|
||
100|[6-9]*) echo %{F$COLOR_FOCUSED_DESKTOP_FG}"▁▃▅▇"
|
||
;;
|
||
[4-5]*) echo %{F$COLOR_FOCUSED_DESKTOP_FG}"▁▃▅""$DARKGREY""▇"%{F$COLOR_FOCUSED_DESKTOP_FG}
|
||
;;
|
||
[1-3]*) echo %{F$COLOR_FOCUSED_DESKTOP_FG}"▁▃""$DARKGREY""▅▇"%{F$COLOR_FOCUSED_DESKTOP_FG}
|
||
;;
|
||
*) echo "$DARKGREY""▁▃▅▇ "%{F$COLOR_FOCUSED_DESKTOP_FG}
|
||
|
||
;;
|
||
esac
|
||
fi
|
||
else
|
||
echo "$DARKGREY$disconnected_icon"%{F$COLOR_FOCUSED_DESKTOP_FG}
|
||
fi
|
||
}
|
||
|
||
battery() {
|
||
BATC=$(cat /sys/class/power_supply/BAT*/capacity)
|
||
BATS=$(cat /sys/class/power_supply/BAT*/status)
|
||
if [ "$BATS" = "Charging" ]; then
|
||
echo "$charging_icon $BATC%"
|
||
else
|
||
case "$BATC" in
|
||
1??|9*) echo "$battery_full_icon $BATC%"
|
||
|
||
;;
|
||
100|[7-8]*) echo "$battery_draining_icon $BATC%"
|
||
|
||
;;
|
||
|
||
[4-6]*) echo "$battery_half_icon $BATC%"
|
||
|
||
;;
|
||
*) echo "$RED$battery_low_icon $BATC%%{F$COLOR_FOCUSED_DESKTOP_FG}"
|
||
|
||
;;
|
||
esac
|
||
fi
|
||
}
|
||
|
||
clock() {
|
||
date '+%I:%M%P '
|
||
}
|
||
|
||
status()
|
||
{
|
||
if [ -e /sys/class/power_supply/BAT*/ ]; then
|
||
if [ "$wifi_indicator" = true ]; then
|
||
while :; do
|
||
echo "C%{A:"$networkmenu":}$(sigStrength)%{A} %{A:dbright:}$(battery)%{A} $time_icon $(clock)"
|
||
sleep "$update_interval"
|
||
done
|
||
else
|
||
while :; do
|
||
echo "C%{A:dbright:}$(battery)%{A} $time_icon $(clock)"
|
||
sleep "$update_interval"
|
||
done
|
||
fi
|
||
else
|
||
if [ "$wifi_indicator" = true ]; then
|
||
while :; do
|
||
echo "C%{A:"$networkmenu":}$(sigStrength)%{A} $time_icon $(clock)"
|
||
sleep "$update_interval"
|
||
done
|
||
else
|
||
while :; do
|
||
echo "C$time_icon $(clock)"
|
||
sleep "$update_interval"
|
||
done
|
||
fi
|
||
fi
|
||
|
||
}
|
||
|
||
lime() {
|
||
while read -r line ; do
|
||
case "$line" in
|
||
S*)
|
||
switcher="%{A:MonocleSwitcher:}${line#?}%{A}"
|
||
;;
|
||
T*)
|
||
title="%{F$COLOR_TITLE}%{B$COLOR_DESKTOP_BG}${line#?}%{B-}%{F-}"
|
||
;;
|
||
C*)
|
||
conky_infos="%{F$COLOR_FOCUSED_DESKTOP_FG}${line#?}"
|
||
;;
|
||
V*)
|
||
volume_infos="${RA}%{F$COLOR_FOCUSED_DESKTOP_FG} ${line#?} "
|
||
;;
|
||
W*)
|
||
# bspwm internal state
|
||
desktops=""
|
||
IFS=':'
|
||
set -- ${line#?}
|
||
while [ $# -gt 0 ] ; do
|
||
item=$1
|
||
name=${item#?}
|
||
case $item in
|
||
# always show focused desktops
|
||
O*|F*|U*)
|
||
desktops="${desktops}%{F$COLOR_FOCUSED_DESKTOP_FG}%{B$COLOR_FOCUSED_DESKTOP_BG}%{U"$COLOR_FOCUSED_DESKTOP_FG"}%{+u}${name}%{-u}$SP%{B-}%{F-}"
|
||
;;
|
||
# show used unfocused (hide free unused)
|
||
o*|u*)#f*
|
||
desktops="${desktops}%{F$COLOR_DESKTOP_FG}%{B$COLOR_DESKTOP_BG}%{A:bspc desktop -f ${name}:}${name}%{A}%{B-}$SP%{F-}"
|
||
;;
|
||
L*)
|
||
# layout
|
||
case "${name}" in
|
||
T) layout_ind=" $tiling_icon" ;;
|
||
M) layout_ind=" $monocle_icon" ;;
|
||
*) layout_ind=" ${name}" ;;
|
||
esac
|
||
layout="%{F$COLOR_DESKTOP_FG}%{B$COLOR_DESKTOP_BG}%{A:bspc desktop -l next:}${layout_ind}%{B-}%{F-}%{A}"
|
||
;;
|
||
esac
|
||
shift
|
||
done
|
||
;;
|
||
esac
|
||
printf "%s\n" "%{l}${logo}${desktops}${layout}${switcher}%{F$COLOR_DESKTOP_FG}%{c}${title}%{r}%{F$COLOR_FOCUSED_DESKTOP_FG}${window_button}$volume_infos${conky_infos}"
|
||
done
|
||
}
|
||
|
||
i=1
|
||
# Remove old fifos and create new ones
|
||
[ -e "$PANEL_FIFO$i" ] && rm "$PANEL_FIFO$i"
|
||
mkfifo "$PANEL_FIFO$i"
|
||
# Wm infos of specific monitor
|
||
bspc subscribe > "$PANEL_FIFO$i" &
|
||
# Title
|
||
xtitle -sf 'T%s\n' -t $title_length > "$PANEL_FIFO$i" &
|
||
# system tray
|
||
if [ "$systemtray" -eq 1 ]; then
|
||
# If there is no configuration, add one
|
||
[ -e ~/.stalonetrayrc ] || cp /usr/share/limepanel/stalonetrayrc ~/.stalonetrayrc
|
||
# Set height to match the panel
|
||
sed -i "s/^icon_size .*/icon_size $PANEL_HEIGHT/" ~/.stalonetrayrc
|
||
sed -i "s/^max_geometry.*/max_geometry 0x$PANEL_HEIGHT/" ~/.stalonetrayrc
|
||
# Try to set position based on the resolution
|
||
if [ -z $tray_pos ]; then
|
||
monitor_width=$(wattr w $(lsw -r))
|
||
tray_pos=$((1600 + $monitor_width - 1920 ))
|
||
echo 'tray_pos=1600' >> ~/.limepanelrc
|
||
sed -i "s/^geometry .*/geometry 1x1+$tray_pos+0/" ~/.stalonetrayrc
|
||
else
|
||
sed -i "s/^geometry .*/geometry 1x1+$tray_pos+0/" ~/.stalonetrayrc
|
||
fi
|
||
sleep 0.2 && stalonetray &
|
||
sleep 0.3 && bspc config top_padding $((panel_height-gap)) &
|
||
|
||
fi
|
||
# status
|
||
status > /tmp/panel-fifo$i &
|
||
# Volume-infos
|
||
autoalsaconf
|
||
volume_status.sh &
|
||
# Pipe all the info to lemonbar
|
||
cat $PANEL_FIFO$i \
|
||
| lime \
|
||
| lemonbar \
|
||
-d \
|
||
-g x$panel_height \
|
||
-f "$mainfont" -o 0\
|
||
-f "$iconfont" -o 0\
|
||
-f "$thirdfont" -o 0\
|
||
-F $COLOR_FOCUSED_DESKTOP_FG \
|
||
-B $COLOR_DESKTOP_BG \
|
||
-U $COLOR_TITLE \
|
||
-a 30 \
|
||
| while read line; do eval "$line"; done &
|
||
#done
|
||
wait
|