Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calendar: calendar display at wrong position for different i3 bar position #485

Open
shivankgarg98 opened this issue Mar 19, 2023 · 2 comments

Comments

@shivankgarg98
Copy link

shivankgarg98 commented Mar 19, 2023

Expected behavior

calendar(yad) dialog should display near calendar button when it is clicked on i3block.

Actual behavior

calendar dialog is displayed at right bottom if i3 bar position is set at top. It is far from i3block button and mouse pointer, making it unclickable.

i3blocks config relevant to blocklet(s)

[calendar]
interval=30
LABEL=
HEIGHT=180
WIDTH=220

Output of any relevant other commands that might help diagnostics

BLOCK_X, BLOCK_Y are not used properly to calculate calendar position.

Suggested Fix

Many people use calendar on upper right corner, using below suggestion can fix the issue (tested on my installation)
Using multiple cases for different i3 bar position and checking screen constraint can give generic fix.

# calculate length of screen
RESOLUTION_X=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1) 
# check calendar is not crossing the screen boundary
posX=$(($BLOCK_X + $WIDTH / 2 > $RESOLUTION_X ? $RESOLUTION_X - $WIDTH : $BLOCK_X - $WIDTH / 2))
posY=0
@shivankgarg98
Copy link
Author

https://ibb.co/RDYtQhX - this is how it looks on my system using above position for yad.

@phcerdan
Copy link

phcerdan commented Jun 2, 2023

Thanks for the solution!
If you have two monitors, the RESOLUTION_X will output two lines, one for each, I added head -n 1 to select the first one (primary monitor).
RESOLUTION_X=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1 | head -n 1)
I guess there are many ways to make that more resilient, but it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants