polybar: Add pop-up calendar to date module
Added calendar (using gsimplecal) which appears on left-clicking the date module. Previous long date format switching has been moved to right-click. Under the hood, the official date module has been exchanged with a custom script which simply replicates the functionality but allows arbitrary commands to be executed on interactions with the module (since it is now a script module).
This commit is contained in:
parent
31a2c283df
commit
65b8fd4820
5 changed files with 48 additions and 6 deletions
|
@ -37,6 +37,7 @@ gnome-keyring
|
||||||
go
|
go
|
||||||
gopls
|
gopls
|
||||||
grub
|
grub
|
||||||
|
gsimplecal
|
||||||
hugo
|
hugo
|
||||||
i3-gaps
|
i3-gaps
|
||||||
i3blocks
|
i3blocks
|
||||||
|
|
|
@ -100,3 +100,4 @@ flexicurity
|
||||||
indices
|
indices
|
||||||
Anthropocene
|
Anthropocene
|
||||||
ecotourism
|
ecotourism
|
||||||
|
legitimation
|
||||||
|
|
|
@ -56,9 +56,10 @@ height = 20
|
||||||
padding-left = 0
|
padding-left = 0
|
||||||
padding-right = 0
|
padding-right = 0
|
||||||
module-margin-left = 2
|
module-margin-left = 2
|
||||||
|
module-margin-right = 2
|
||||||
|
|
||||||
modules-left = sxhkdmode workspaces pomo papersdue
|
modules-left = sxhkdmode workspaces pomo papersdue
|
||||||
modules-center = music date
|
modules-center = music datecal
|
||||||
modules-right = dunstpaused networkspeed mail weather archupdates cpu temp volume battery
|
modules-right = dunstpaused networkspeed mail weather archupdates cpu temp volume battery
|
||||||
; do not use offsets for the bar, would only work with override-redirect
|
; do not use offsets for the bar, would only work with override-redirect
|
||||||
; and will mess up tray https://github.com/polybar/polybar/issues/1355
|
; and will mess up tray https://github.com/polybar/polybar/issues/1355
|
||||||
|
@ -222,7 +223,15 @@ time = %H:%M
|
||||||
; the module will toggle between formats
|
; the module will toggle between formats
|
||||||
date-alt = %A, %d %B %Y (W %V)
|
date-alt = %A, %d %B %Y (W %V)
|
||||||
time-alt = %H:%M:%S
|
time-alt = %H:%M:%S
|
||||||
label = %date%%{T2} %{T-}%time%
|
label = %date%%{T2} %{T-}%time%
|
||||||
|
format-underline = ${colors.primary}
|
||||||
|
|
||||||
|
[module/datecal]
|
||||||
|
type = custom/script
|
||||||
|
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-date
|
||||||
|
tail = true
|
||||||
|
click-left = gsimplecal
|
||||||
|
click-right = kill -USR1 %pid%
|
||||||
format-underline = ${colors.primary}
|
format-underline = ${colors.primary}
|
||||||
|
|
||||||
; display information on currently playing track, allows simple track manipulation
|
; display information on currently playing track, allows simple track manipulation
|
||||||
|
@ -268,7 +277,7 @@ format-underline = ${colors.primary}
|
||||||
|
|
||||||
[module/weather]
|
[module/weather]
|
||||||
type = custom/script
|
type = custom/script
|
||||||
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-weather '?format=%t+%C+(%p)'
|
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-weather 'Copenhagen?m&format=%t+%C+(%p)'
|
||||||
exec-if = type $XDG_CONFIG_HOME/polybar/scripts/poly-weather
|
exec-if = type $XDG_CONFIG_HOME/polybar/scripts/poly-weather
|
||||||
interval = 60.0
|
interval = 60.0
|
||||||
; format-background = ${colors.primary}
|
; format-background = ${colors.primary}
|
||||||
|
|
31
polybar/.config/polybar/scripts/poly-date
Executable file
31
polybar/.config/polybar/scripts/poly-date
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
update_time=5
|
||||||
|
mode=${1:-0}
|
||||||
|
separator=' '
|
||||||
|
short_date_string='%d/%m'"${separator}"'%H:%M'
|
||||||
|
long_date_string='%A, %d %B %Y (CW %V)'"${separator}"'%H:%M:%S'
|
||||||
|
|
||||||
|
modetoggle() {
|
||||||
|
mode=$(((mode + 1) % 2))
|
||||||
|
}
|
||||||
|
trap "modetoggle" USR1
|
||||||
|
|
||||||
|
display_date() {
|
||||||
|
if [ "$1" = "long" ]; then
|
||||||
|
date +"${long_date_string}"
|
||||||
|
else
|
||||||
|
date +"${short_date_string}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if [ $mode -eq 0 ]; then
|
||||||
|
display_date short
|
||||||
|
elif [ $mode -eq 1 ]; then
|
||||||
|
display_date long
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep $update_time &
|
||||||
|
wait
|
||||||
|
done
|
|
@ -3,7 +3,7 @@
|
||||||
wttr() {
|
wttr() {
|
||||||
# change Paris to your default location
|
# change Paris to your default location
|
||||||
request="wttr.in/${1-~Leipzig}"
|
request="wttr.in/${1-~Leipzig}"
|
||||||
curl -s -H "Accept-Language: ${LANG%_*}" --compressed "$request"
|
curl -s -H "Accept-Language: ${LANG%_*}" --compressed "${request}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wttr "$@"
|
wttr "$@"
|
||||||
|
|
Loading…
Reference in a new issue