i3/polybar: calendar

This commit is contained in:
Michael Grote 2021-06-28 21:55:44 +02:00
parent e0db4cc5e0
commit fdc9d394a1
3 changed files with 52 additions and 2 deletions

View file

@ -192,3 +192,6 @@ exec_always --no-startup-id /home/mg/dotfiles/polybar/launch.sh
# feh # feh
exec --no-startup-id /usr/bin/feh --bg-scale /home/mg/dotfiles/i3/wallpaper/dogg.jpg exec --no-startup-id /usr/bin/feh --bg-scale /home/mg/dotfiles/i3/wallpaper/dogg.jpg
# polybar/popup-calendar
for_window [class="Yad" title="yad-calendar"] floating enable

View file

@ -39,8 +39,8 @@ font-0 = fixed:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0 font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = siji:pixelsize=10;1 font-2 = siji:pixelsize=10;1
modules-left = i3 modules-left = i3
modules-center = modules-center = popup-calendar
modules-right = nightscout_script backlight alsa memory cpu wlan eth_intern eth_dock battery date powermenu modules-right = nightscout_script backlight alsa memory cpu wlan eth_intern eth_dock battery date powermenu
tray-position = right tray-position = right
tray-padding = 2 tray-padding = 2
tray-background = #888888 tray-background = #888888
@ -57,6 +57,12 @@ exec = /home/mg/dotfiles/polybar/nightscout_cgm.sh
interval = 120 interval = 120
format-prefix = "BZ " format-prefix = "BZ "
[module/popup-calendar]
type = custom/script
exec = /home/mg/dotfiles/polybar/popup-calendar.sh
interval = 5
click-left = /home/mg/dotfiles/polybar/popup-calendar.sh --popup &
[module/xwindow] [module/xwindow]
type = internal/xwindow type = internal/xwindow
label = %title:0:30:...% label = %title:0:30:...%

41
polybar/popup-calendar.sh Normal file
View file

@ -0,0 +1,41 @@
#!/bin/sh
BAR_HEIGHT=22 # polybar height
BORDER_SIZE=1 # border size from your wm settings
YAD_WIDTH=222 # 222 is minimum possible value
YAD_HEIGHT=193 # 193 is minimum possible value
DATE="$(date +"%a %d %H:%M")"
case "$1" in
--popup)
if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
exit 0
fi
eval "$(xdotool getmouselocation --shell)"
eval "$(xdotool getdisplaygeometry --shell)"
# X
if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
: $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
: $((pos_x = BORDER_SIZE))
else #Center
: $((pos_x = X - YAD_WIDTH / 2))
fi
# Y
if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
: $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
else #Top
: $((pos_y = BAR_HEIGHT + BORDER_SIZE))
fi
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
--width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \
--title="yad-calendar" --borders=0 >/dev/null &
;;
*)
echo "$DATE"
;;
esac