popup-calendar: fix positions
This commit is contained in:
parent
414e8d1640
commit
466927f976
@ -16,16 +16,16 @@ A small script that displays the date and opens a small popup calendar with YAD
|
|||||||
Change these values if you want:
|
Change these values if you want:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
BAR_HEIGHT=22
|
||||||
YAD_WIDTH=200
|
YAD_WIDTH=200
|
||||||
YAD_HEIGHT=200
|
YAD_HEIGHT=200
|
||||||
BOTTOM=false
|
|
||||||
DATE="$(date +"%a %d %H:%M")"
|
DATE="$(date +"%a %d %H:%M")"
|
||||||
```
|
```
|
||||||
|
|
||||||
If you use a tiling window manager you should enable floating for `yad`. This example is for `i3wm`:
|
If you use a tiling window manager you should enable floating for `yad-calendar`. This example is for `i3wm`:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
for_window [class="Yad"] floating enable
|
for_window [class="Yad" title="yad-calendar"] floating enable
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,25 +1,34 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
BAR_HEIGHT=22
|
||||||
YAD_WIDTH=200
|
YAD_WIDTH=200
|
||||||
YAD_HEIGHT=200
|
YAD_HEIGHT=200
|
||||||
BOTTOM=false
|
|
||||||
DATE="$(date +"%a %d %H:%M")"
|
DATE="$(date +"%a %d %H:%M")"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--popup)
|
--popup)
|
||||||
eval "$(xdotool getmouselocation --shell)"
|
eval "$(xdotool getmouselocation --shell)"
|
||||||
|
eval "$(xdotool getdisplaygeometry --shell)"
|
||||||
|
|
||||||
if [ $BOTTOM = true ]; then
|
# X
|
||||||
: $(( pos_y = Y - YAD_HEIGHT - 20 ))
|
if [ "$((X + 35 + YAD_WIDTH / 2))" -gt "$WIDTH" ]; then #Right side
|
||||||
: $(( pos_x = X - (YAD_WIDTH / 2) ))
|
: $((pos_x = WIDTH - 35 - YAD_WIDTH))
|
||||||
else
|
elif [ "$((X - YAD_WIDTH / 2))" -lt 1 ]; then #Left side
|
||||||
: $(( pos_y = Y + 20 ))
|
: $((pos_x = 10))
|
||||||
: $(( pos_x = X - (YAD_WIDTH / 2) ))
|
else #Center
|
||||||
|
: $((pos_x = X - YAD_WIDTH / 2))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Y
|
||||||
|
if [ "$((Y + YAD_HEIGHT))" -gt "$HEIGHT" ]; then #Bottom
|
||||||
|
: $((pos_y = HEIGHT - BAR_HEIGHT - YAD_HEIGHT))
|
||||||
|
else #Top
|
||||||
|
: $((pos_y = Y + BAR_HEIGHT))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
|
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
|
||||||
--width=$YAD_WIDTH --height=$YAD_HEIGHT --posx=$pos_x --posy=$pos_y \
|
--width=$YAD_WIDTH --height=$YAD_HEIGHT --posx=$pos_x --posy=$pos_y \
|
||||||
> /dev/null
|
--title="yad-calendar" >/dev/null
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$DATE"
|
echo "$DATE"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user