added bluetooth module; replaced bars with ramps
This commit is contained in:
@@ -20,21 +20,17 @@ padding-right = 1
|
||||
module-margin-left = 1
|
||||
module-margin-right = 2
|
||||
|
||||
modules-left = i3 pulseaudio xbacklight
|
||||
modules-left = i3 pulseaudio xbacklight battery-custom
|
||||
modules-center = datetime
|
||||
modules-right = battery-custom vpn wlan powermenu
|
||||
modules-right = vpn wlan bluetooth powermenu
|
||||
|
||||
tray-position = right
|
||||
tray-detached = false
|
||||
tray-scale = 1.0
|
||||
|
||||
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
|
||||
font-2 = MesloLGS NF:size=18;-2
|
||||
; used for small space in scripts/battery.sh
|
||||
font-3 = MesloLGS NF:size=8
|
||||
font-1 = MesloLGS NF:size=18;-2
|
||||
background = ${colors.background}
|
||||
foreground = ${colors.foreground}
|
||||
line-size = 3
|
||||
@@ -73,40 +69,42 @@ label-urgent-padding = ${self.label-focused-padding}
|
||||
[module/pulseaudio]
|
||||
type = internal/pulseaudio
|
||||
|
||||
format-volume = <label-volume> <bar-volume>
|
||||
label-volume = VOL: %percentage%%
|
||||
label-muted = VOL: muted
|
||||
bar-volume-width = 10
|
||||
bar-volume-empty = -
|
||||
bar-volume-fill = -
|
||||
bar-volume-indicator = |
|
||||
format-volume = <ramp-volume> <label-volume>
|
||||
label-volume = %percentage%%
|
||||
label-muted = 婢
|
||||
|
||||
;format-volume = <ramp-volume> <label-volume>
|
||||
;format-volume-font = 2
|
||||
;label-muted = muted
|
||||
;
|
||||
;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 = ██████████
|
||||
ramp-volume-0 = 奔
|
||||
ramp-volume-1 = 墳
|
||||
ramp-volume-2 =
|
||||
|
||||
;#################################################
|
||||
|
||||
[module/xbacklight]
|
||||
type = internal/xbacklight
|
||||
format = <label> <bar>
|
||||
label = BL: %percentage%%
|
||||
bar-width = 10
|
||||
bar-empty = -
|
||||
bar-fill = -
|
||||
bar-indicator = |
|
||||
format = <ramp> <label>
|
||||
label = %percentage%%
|
||||
|
||||
ramp-0 =
|
||||
ramp-1 =
|
||||
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,13 +123,6 @@ label = "%date% - %time%"
|
||||
;#################################################
|
||||
;#################################################
|
||||
|
||||
[module/battery-custom]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/battery.sh
|
||||
interval = 5
|
||||
|
||||
;#################################################
|
||||
|
||||
[module/vpn]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/running-vpn.sh
|
||||
@@ -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]
|
||||
type = custom/text
|
||||
content = %{A1:~/.config/rofi/powermenu.sh &:}%{T3}...%{T-}%{A}
|
||||
content = %{A1:~/.config/rofi/powermenu.sh &:}%{T2}...%{T-}%{A}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
## config
|
||||
|
||||
@@ -10,18 +10,20 @@ low=20
|
||||
red='%{F#f00}'
|
||||
green='%{F#0f0}'
|
||||
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)"
|
||||
ac="$(cat /sys/class/power_supply/AC/online)"
|
||||
declare -a ramp
|
||||
ramp=( )
|
||||
|
||||
# display in red when under $low and no charger is connected
|
||||
[ "$bat" -gt "$low" ] || [ "$ac" -eq 1 ] || color="$red"
|
||||
# display in green when over $full and a charger is connected
|
||||
[ "$bat" -lt "$full" ] || [ "$ac" -eq 0 ] || color="$green"
|
||||
|
||||
prefix=" "
|
||||
[ "$ac" -eq 0 ] || prefix="⚡"
|
||||
let "icon_index = $bat / (${#ramp[@]} - 1)"
|
||||
[ $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}%"
|
||||
|
||||
68
.config/polybar/scripts/bluetooth.sh
Executable file
68
.config/polybar/scripts/bluetooth.sh
Executable 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
|
||||
|
||||
Reference in New Issue
Block a user