added bluetooth module; replaced bars with ramps

This commit is contained in:
2020-04-28 01:57:04 +02:00
parent 758b6e5713
commit e7d8ed55ed
3 changed files with 119 additions and 50 deletions

View File

@@ -20,21 +20,17 @@ padding-right = 1
module-margin-left = 1 module-margin-left = 1
module-margin-right = 2 module-margin-right = 2
modules-left = i3 pulseaudio xbacklight modules-left = i3 pulseaudio xbacklight battery-custom
modules-center = datetime modules-center = datetime
modules-right = battery-custom vpn wlan powermenu modules-right = vpn wlan bluetooth powermenu
tray-position = right tray-position = right
tray-detached = false tray-detached = false
tray-scale = 1.0 tray-scale = 1.0
font-0 = MesloLGS NF:style=Regular:size=18;4 font-0 = MesloLGS NF:style=Regular:size=18;4
; used for the colume ramp
font-1 = MesloLGS NF:style=Regular:size=10;2
; used for the dots in module/powermenu ; used for the dots in module/powermenu
font-2 = MesloLGS NF:size=18;-2 font-1 = MesloLGS NF:size=18;-2
; used for small space in scripts/battery.sh
font-3 = MesloLGS NF:size=8
background = ${colors.background} background = ${colors.background}
foreground = ${colors.foreground} foreground = ${colors.foreground}
line-size = 3 line-size = 3
@@ -73,40 +69,42 @@ label-urgent-padding = ${self.label-focused-padding}
[module/pulseaudio] [module/pulseaudio]
type = internal/pulseaudio type = internal/pulseaudio
format-volume = <label-volume> <bar-volume> format-volume = <ramp-volume> <label-volume>
label-volume = VOL: %percentage%% label-volume = %percentage%%
label-muted = VOL: muted label-muted =
bar-volume-width = 10
bar-volume-empty = -
bar-volume-fill = -
bar-volume-indicator = |
;format-volume = <ramp-volume> <label-volume> ramp-volume-0 = 奔
;format-volume-font = 2 ramp-volume-1 =
;label-muted = muted ramp-volume-2 = 
;
;ramp-volume-0 =  
;ramp-volume-1 = █ 
;ramp-volume-2 = ██ 
;ramp-volume-3 = ███ 
;ramp-volume-4 = ████ 
;ramp-volume-5 = █████ 
;ramp-volume-6 = ██████ 
;ramp-volume-7 = ███████ 
;ramp-volume-8 = ████████ 
;ramp-volume-9 = █████████ 
;ramp-volume-10 = ██████████
;################################################# ;#################################################
[module/xbacklight] [module/xbacklight]
type = internal/xbacklight type = internal/xbacklight
format = <label> <bar> format = <ramp> <label>
label = BL: %percentage%% label = %percentage%%
bar-width = 10
bar-empty = - ramp-0 =
bar-fill = - ramp-1 =
bar-indicator = | ramp-2 =
ramp-3 = 
ramp-4 = 
ramp-5 = 
ramp-6 = 
ramp-7 = 
ramp-8 = 
ramp-9 = 
ramp-10 = 
ramp-11 = 
ramp-12 = 
ramp-13 = 
;#################################################
[module/battery-custom]
type = custom/script
exec = ~/.config/polybar/scripts/battery.sh
interval = 5
;################################################# ;#################################################
;################################################# ;#################################################
@@ -125,17 +123,10 @@ label = "%date% - %time%"
;################################################# ;#################################################
;################################################# ;#################################################
[module/battery-custom]
type = custom/script
exec = ~/.config/polybar/scripts/battery.sh
interval = 5
;#################################################
[module/vpn] [module/vpn]
type = custom/script type = custom/script
exec = ~/.config/polybar/scripts/running-vpn.sh exec = ~/.config/polybar/scripts/running-vpn.sh
click-left = ~/.config/polybar/scripts/pub-ipv4.sh & click-left = ~/.config/polybar/scripts/pub-ipv4.sh &
interval = 5 interval = 5
;################################################# ;#################################################
@@ -153,7 +144,15 @@ label-disconnected = %{A1:gnome-terminal -x nmtui connect:} %ifname% disconnecte
;################################################# ;#################################################
[module/bluetooth]
type = custom/script
exec = ~/.config/polybar/scripts/bluetooth.sh
tail = true
click-left = ~/.config/polybar/scripts/bluetooth.sh --toggle &
;#################################################
[module/powermenu] [module/powermenu]
type = custom/text type = custom/text
content = %{A1:~/.config/rofi/powermenu.sh &:}%{T3}...%{T-}%{A} content = %{A1:~/.config/rofi/powermenu.sh &:}%{T2}...%{T-}%{A}

View File

@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
## config ## config
@@ -10,18 +10,20 @@ low=20
red='%{F#f00}' red='%{F#f00}'
green='%{F#0f0}' green='%{F#0f0}'
end='%{F-}' end='%{F-}'
# hack to put a little space between the lightning and the percentage
smallspace='%{T4} %{T-}'
bat="$(cat /sys/class/power_supply/BAT0/capacity)" bat="$(cat /sys/class/power_supply/BAT0/capacity)"
ac="$(cat /sys/class/power_supply/AC/online)" ac="$(cat /sys/class/power_supply/AC/online)"
declare -a ramp
ramp=(          )
# display in red when under $low and no charger is connected # display in red when under $low and no charger is connected
[ "$bat" -gt "$low" ] || [ "$ac" -eq 1 ] || color="$red" [ "$bat" -gt "$low" ] || [ "$ac" -eq 1 ] || color="$red"
# display in green when over $full and a charger is connected # display in green when over $full and a charger is connected
[ "$bat" -lt "$full" ] || [ "$ac" -eq 0 ] || color="$green" [ "$bat" -lt "$full" ] || [ "$ac" -eq 0 ] || color="$green"
prefix=" " let "icon_index = $bat / (${#ramp[@]} - 1)"
[ "$ac" -eq 0 ] || prefix="⚡" [ $icon_index -lt ${#ramp[@]} ] || icond_index=10
icon="${ramp[$icon_index]}"
[ "$ac" -eq 0 ] || charge=""
echo "${color}${prefix}${smallspace}${bat}%" echo "${color}${icon}${charge} ${bat}%"

View File

@@ -0,0 +1,68 @@
#!/bin/bash
# See https://github.com/polybar/polybar-scripts/pull/237
bluetooth_print() {
bluetoothctl | while read -r; do
if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then
devices_paired=$(echo paired-devices | bluetoothctl | sed -n '/paired-devices/,$p' | grep Device | cut -d ' ' -f 2)
counter=0
echo "$devices_paired" | while read -r line; do
device_info=$(echo "info $line" | bluetoothctl)
if echo "$device_info" | grep -q "Connected: yes"; then
device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
if [ $counter -gt 0 ]; then
printf ", %s" "$device_alias"
else
printf ": %s" "$device_alias"
fi
counter=$((counter + 1))
fi
done
if echo show | bluetoothctl | grep -q "Powered: no"; then
printf ''
fi
printf '\n'
else
echo ""
fi
done
}
bluetooth_toggle() {
if echo show | bluetoothctl | grep -q "Powered: no"; then
echo "power on" | bluetoothctl >> /dev/null
sleep 1
devices_paired=$(echo paired-devices | bluetoothctl | sed -n '/paired-devices/,$p' | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
echo "connect $line" | bluetoothctl >> /dev/null
done
else
devices_paired=$(echo paired-devices | bluetoothctl | sed -n '/paired-devices/,$p' | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
device_info=$(echo "info $line" | bluetoothctl)
if echo "$device_info" | grep -q "Connected: yes"; then
echo "disconnect $line" | bluetoothctl >> /dev/null
fi
done
echo "power off" | bluetoothctl >> /dev/null
fi
}
case "$1" in
--toggle)
bluetooth_toggle
;;
*)
bluetooth_print
;;
esac