Calendar pop-up

I want ‘gsimplecal’ to pop up when I click on the ‘date’ on the i3bar
I looked through the config directory for i3 but couldn’t figure it out.

Any tips would be greatly appreciated.

Thank you

You might want to read into this thread, in order to learn what a possible solution could look like. :wink:

1 Like

I am not sure about gsimplecal but I got mine from this script. It was designed for polybar but in fact it is just a regular shell script that starts a yad calendar so it can probably work with i3bar as well.

i think i use this here for a very long time… wait a minute so i can check my config…

# Date Time
[time]
label=
command=date '+%a %d %b %Y %H:%M:%S' ; [[ -z "${BLOCK_BUTTON}" ]] || gsimplecal &
color=#dbcb75
interval=1
2 Likes

Thank you guys @anon11595408 and @joekamprad you both gave me the solutions

I had to add:

for_window [class="(?i)gsimplecal"] floating enable, move position mouse, move down $height px

from the forum link otherwise it would go below the bar partially

1 Like

2023-05-08_08-15
no clue why it is not doing this here i have nop extra rule for it in my config

I found an easy working solution for a clickable calendar on i3blocks, looking good to me plus easy setup:

See:

1 Like

if you know how to set the cal. to not pop up on current focussed workspace and instead always sit on top of the date time panel part ? :wink:

1 Like

Guess not (yet).

Tried commenting the line # --close-on-unfocus --no-buttons \ but then it appears in the middle of the screen (not respecting posx & posy) and stays with buttons (Cancel & Ok) until you click either. :wink:

Here’s “my” calendar with adjusted positions from the original:

Summary
#!/usr/bin/env sh

WIDTH=${WIDTH:-200}
HEIGHT=${HEIGHT:-200}
DATEFMT=${DATEFMT:-"+%a %d.%m.%Y %H:%M:%S"}
SHORTFMT=${SHORTFMT:-"+%H:%M:%S"}

OPTIND=1
while getopts ":f:W:H:" opt; do
    case $opt in
        f) DATEFMT="$OPTARG" ;;
        W) WIDTH="$OPTARG" ;;
        H) HEIGHT="$OPTARG" ;;
        \?)
            echo "Invalid option: -$OPTARG" >&2
            exit 1
            ;;
        :)
            echo "Option -$OPTARG requires an argument." >&2
            exit 1
            ;;
    esac
done

case "$BLOCK_BUTTON" in
  1|2|3) 

	# the position of the upper left corner of the popup
#	posX=$(($BLOCK_X - $WIDTH / 2))
	posX=$(($BLOCK_X - 85))
#	posY=$(($BLOCK_Y - $HEIGHT))
	posY=$(($BLOCK_Y - 260))

	i3-msg -q "exec yad --calendar \
        --width=$WIDTH --height=$HEIGHT \
	    --undecorated --fixed \
	    --close-on-unfocus --no-buttons \
	    --posx=$posX --posy=$posY \
	    > /dev/null"
esac
echo "$LABEL$(date "$DATEFMT")"
echo "$LABEL$(date "$SHORTFMT")"
1 Like

The examples above are calling calendars from yad. You can then specify something like

yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
        --width=$YAD_WIDTH --height=$YAD_HEIGHT --posx=$pos_x --posy=$pos_y \
        --title="yad-calendar" >/dev/null &

The important is --title="yad-calendar" because then you can use i3config

for_window [class="Yad" title="yad-calendar"] floating enable, move container to workspace 4

You can also call

eval "$(xdotool getmouselocation --shell)"
eval "$(xdotool getdisplaygeometry --shell)"

in you script to get current position of mouse and geometry of the window if that is useful for you.

2 Likes

Thanks! This works as you described! :v:

If you don’t add the line to the i3config, the behavior is a little different:
On used (filled) workspaces it works as before (i.e. --close-on-unfocus) - but when you click on it in an empty workspace, the calendar stays in it’s position (as long as the screen isn’t used by another app, or you quit it on focus with the esc key…

The EnOS i3config already has a line without the title="calendar" string:
for_window [class="Yad"] floating enable.

…I still added the string --title="yad-calendar" to the calendar script.

So two different options for @joekamprad :wink:

AWESOME!
Really nice…

but indeed… workspaces do change somhow it would need to get moved to the visable workspace on the display where i click it…

as… clicking on the bar does not change the focus…

I played with the option --no-focus (dialog window never take focus, see man yad) but couldn’t get it to do just that.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.