phillbush / xmenu

a x11 menu utility
Other
296 stars 26 forks source link

XParseGeometry docs and xmenu docs causes ambiguity for positioning #58

Open Avinash-Bhat opened 2 months ago

Avinash-Bhat commented 2 months ago

According to the xmenu documentation, XParseGeometry is used for parsing the (first part of) -p option.

The XParseGeometry documentation says the format should be:

[=][<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]

But when invoking xmenu using xmenu -p 0x0 it shows at position 0,0 (top-left) of the monitor. If I'm not wrong here, following the documentation of XParseGeometry, we should be invoking xmenu -p '+0+0' instead for the same behavior. This causes some ambiguity in positioning the menus.

On the same note, using xmenu -p '-0-0' should theoretically place it at the bottom right of the monitor which would be a good use-case to considering the user is left to do xrandr math in shell.

I'm sure that there are other users who would want to do the same.

personal note:

I ran into this weirdness when I was creating a power menu using xmenu.

#!/bin/sh
POSITION=$(xrandr --query |awk -F '[ x+]' '/\<primary\>/{print $4-(8*2)"x"$5-(95*2)}')
echo $POSITION
xmenu -p ${POSITION}:cursor <<EOF | sh &
Shutdown            systemctl poweroff
Reboot              systemctl reboot
Hibernate           loginctl lock-session $XDG_SESSION_ID && systemctl hibernate
Sleep               loginctl lock-session $XDG_SESSION_ID && systemctl suspend
Logout              i3-msg exit
Lock                loginctl lock-session $XDG_SESSION_ID
EOF

whenever I added a new item to the menu I have to adjust the y-position using awk as the height of the menu changes.

I hope you see that this is a bit awkward to work with.