Battery percentage

This commit is contained in:
Christian Colglazier 2020-10-24 11:56:28 -04:00
parent 1056b9292a
commit 4b91be7b57
3 changed files with 32 additions and 26 deletions

View File

@ -72,6 +72,11 @@ bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# media controls
bindsym Ctrl+Left exec playerctl previous
bindsym Ctrl+Down exec playerctl play-pause
bindsym Ctrl+Right exec playerctl next
# Gaps
set $inner 16
set $outer 0

View File

@ -37,7 +37,7 @@ font-5 = Font Awesome 5 Free Solid:pixelsize=70;3
modules-left = i3
modules-center = xwindow
modules-right = backlight volume network battery date
modules-right = backlight volume network battery mouse-battery date
tray-position = right
tray-padding = 2
@ -47,42 +47,26 @@ type = internal/xwindow
label = %title:0:80:...%
format-background = ${colors.black}
[module/bspwm]
type = internal/bspwm
label-focused = %index%
label-focused-background = ${colors.blue}
label-focused-underline= ${colors.pink}
label-focused-padding = 2
label-occupied = %index%
label-occupied-padding = 2
label-urgent = %index%!
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
label-empty = %index%
label-empty-foreground = ${colors.foreground-alt}
label-empty-padding = 2
[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false
strip-wsnumbers = true
fuzzy-match = true
label-mode-padding = 2
label-mode-foreground = #000
label-mode-background = ${colors.pink}
label-focused = %index%
label-focused-background = ${module/bspwm.label-focused-background}
label-focused-underline = ${module/bspwm.label-focused-underline}
label-focused-padding = ${module/bspwm.label-focused-padding}
label-focused-background = ${colors.blue}
label-focused-underline = ${colors.pink}
label-focused-padding = 2
label-unfocused = %index%
label-unfocused-padding = ${module/bspwm.label-occupied-padding}
label-unfocused-padding = 2
label-visible = %index%
label-visible-background = ${self.label-focused-background}
@ -90,8 +74,8 @@ label-visible-underline = ${self.label-focused-background}
label-visible-padding = ${self.label-focused-padding}
label-urgent = %index%!
label-urgent-background = ${module/bspwm.label-urgent-background}
label-urgent-padding = ${module/bspwm.label-urgent-padding}
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
[module/date]
type = internal/date
@ -192,6 +176,12 @@ label-connected-underline = ${colors.blue}
label-disconnected =
label-disconnected-underline = ${colors.pink}
[module/mouse-battery]
type = custom/script
exec = ~/.config/scripts/get-mouse-battery.sh
label = %output%
interval = 60
[settings]
screenchange-reload = true
;compositing-background = xor

11
scripts/get-mouse-battery.sh Executable file
View File

@ -0,0 +1,11 @@
#! /bin/bash
mouseState=$(upower -i /org/freedesktop/UPower/devices/mouse_hidpp_battery_0)
batteryPercentage=$(echo $mouseState | grep percentage | grep -Po '\d+%')
charging=$(echo $mouseState | grep 'state: charging')
if [ ! -z "$charging" ]; then
echo Charging
else
echo $batteryPercentage
fi