polybar: Add calendar popup on date-module click
This commit is contained in:
@@ -187,6 +187,12 @@ for_window [class="^TelegramDesktop$"] \
|
|||||||
scratchpad show
|
scratchpad show
|
||||||
bindsym $mod+Shift+t [class="^TelegramDesktop$"] scratchpad show
|
bindsym $mod+Shift+t [class="^TelegramDesktop$"] scratchpad show
|
||||||
|
|
||||||
|
for_window [class="^$TERMINAL-256color$" title="^polybar-datetime-calendar$"] \
|
||||||
|
floating enable, \
|
||||||
|
border pixel 3, \
|
||||||
|
resize set 378 300, \
|
||||||
|
move position 1411 32
|
||||||
|
|
||||||
# screenshots
|
# screenshots
|
||||||
bindsym --release Print exec gnome-screenshot -i
|
bindsym --release Print exec gnome-screenshot -i
|
||||||
bindsym --release $mod+Print exec gnome-screenshot -a
|
bindsym --release $mod+Print exec gnome-screenshot -a
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ interval = 1
|
|||||||
date = %Y-%m-%d%
|
date = %Y-%m-%d%
|
||||||
time = "%H:%M:%S "
|
time = "%H:%M:%S "
|
||||||
|
|
||||||
label = "%date% - %time%"
|
label = ${env:POLYBAR_DATETIME}
|
||||||
|
|
||||||
;#################################################
|
;#################################################
|
||||||
;#################################################
|
;#################################################
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
XDG_CONF="${XDG_CONFIG_HOME:-$HOME/.config}"
|
XDG_CONF="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
BASE_DIR="$XDG_CONF/polybar"
|
BASE_DIR="$XDG_CONF/polybar"
|
||||||
|
|
||||||
|
calendar_exec="st -A 0.45 -t polybar-datetime-calendar \"$BASE_DIR/scripts/calendar.sh\" &"
|
||||||
declare -A module_flags
|
declare -A module_flags
|
||||||
module_flags=(
|
module_flags=(
|
||||||
[battery]="$BASE_DIR/scripts/battery.sh"
|
[battery]="$BASE_DIR/scripts/battery.sh"
|
||||||
[bluetooth]="$BASE_DIR/scripts/bluetooth.sh"
|
[bluetooth]="$BASE_DIR/scripts/bluetooth.sh"
|
||||||
[bluetooth_click_left]="$BASE/scripts/bluetooth.sh --toggle &"
|
[bluetooth_click_left]="$BASE/scripts/bluetooth.sh --toggle &"
|
||||||
|
[datetime]="%{A1:$calendar_exec:} %date% - %time% %{A}"
|
||||||
[media]="$BASE_DIR/scripts/media.sh"
|
[media]="$BASE_DIR/scripts/media.sh"
|
||||||
[powermenu]="%{A1:$XDG_CONF/rofi/powermenu.sh &:}%{T2}...%{T-}%{A}"
|
[powermenu]="%{A1:$XDG_CONF/rofi/powermenu.sh &:}%{T2}...%{T-}%{A}"
|
||||||
[vpn]="$BASE_DIR/scripts/vpn.sh"
|
[vpn]="$BASE_DIR/scripts/vpn.sh"
|
||||||
|
|||||||
46
.config/polybar/scripts/calendar.sh
Executable file
46
.config/polybar/scripts/calendar.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# The separation and recursion is sadly necessary since reload is apparently
|
||||||
|
# executed in a subshell and thus using an environment variable does not work
|
||||||
|
|
||||||
|
dn="reload(\"$0\" -)"
|
||||||
|
up="reload(\"$0\" +)"
|
||||||
|
FZF_ARGS=(
|
||||||
|
--reverse
|
||||||
|
--no-sort
|
||||||
|
--no-info
|
||||||
|
--phony
|
||||||
|
--prompt=
|
||||||
|
--bind="ctrl-j:$dn,down:$dn,ctrl-k:$up,up:$up,enter:abort"
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
# Frontend
|
||||||
|
|
||||||
|
# Create temporary file for the counter that should be removed when exiting.
|
||||||
|
export FZF_CAL_TMP="$(mktemp)"
|
||||||
|
trap "rm -f $FZF_CAL_TMP" EXIT
|
||||||
|
echo 0 > "$FZF_CAL_TMP"
|
||||||
|
|
||||||
|
# Call fzf
|
||||||
|
cal -wm | fzf "${FZF_ARGS[@]}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
# Backend
|
||||||
|
|
||||||
|
# + Add to counter, going back in time
|
||||||
|
# - Subtract from counter, going forward in time
|
||||||
|
# = Print current month without modifying the counter
|
||||||
|
[[ $1 = "+" || $1 = "-" || $1 = "=" ]] || exit 1
|
||||||
|
[[ -n $FZF_CAL_TMP ]] || exit 1
|
||||||
|
|
||||||
|
counter=$(cat "$FZF_CAL_TMP")
|
||||||
|
if [[ $1 != "=" ]]; then
|
||||||
|
# Increment or decrement counter
|
||||||
|
: $((counter$1$1))
|
||||||
|
echo $counter >"$FZF_CAL_TMP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print calendar
|
||||||
|
cal -wm $(date +"%m %Y" -d "$counter months ago")
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user