Skip to content

Commit

Permalink
popup-calendar: add script
Browse files Browse the repository at this point in the history
  • Loading branch information
mjturt authored and x70b1 committed Jul 22, 2018
1 parent 9f98144 commit e0b98c6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
40 changes: 40 additions & 0 deletions polybar-scripts/popup-calendar/README.md
@@ -0,0 +1,40 @@
# Script: popup-calendar

A small script that displays the date and opens a small popup calendar with YAD when clicked.

![popup-calendar](screenshots/1.png)


## Dependencies

* [`yad`](https://sourceforge.net/projects/yad-dialog/)
* `xdotool`


## Configuration

Change these values if you want:

```sh
YAD_WIDTH=200
YAD_HEIGHT=200
BOTTOM=false
DATE="$(date +"%a %d %H:%M")"
```

If you use a tiling window manager you should enable floating for `yad`. This example is for `i3wm`:

```ini
for_window [class="Yad"] floating enable
```


## Module

```ini
[module/popup-calendar]
type = custom/script
exec = ~/polybar-scripts/popup-calendar.sh
interval = 5
click-left = ~/polybar-scripts/popup-calendar.sh --popup
```
27 changes: 27 additions & 0 deletions polybar-scripts/popup-calendar/popup-calendar.sh
@@ -0,0 +1,27 @@
#!/bin/sh

YAD_WIDTH=200
YAD_HEIGHT=200
BOTTOM=false
DATE="$(date +"%a %d %H:%M")"

case "$1" in
--popup)
eval "$(xdotool getmouselocation --shell)"

if [ $BOTTOM = true ]; then
: $(( pos_y = Y - YAD_HEIGHT - 20 ))
: $(( pos_x = X - (YAD_WIDTH / 2) ))
else
: $(( pos_y = Y + 20 ))
: $(( pos_x = X - (YAD_WIDTH / 2) ))
fi

yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
--width=$YAD_WIDTH --height=$YAD_HEIGHT --posx=$pos_x --posy=$pos_y \
> /dev/null
;;
*)
echo "$DATE"
;;
esac
Binary file added polybar-scripts/popup-calendar/screenshots/1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0b98c6

Please sign in to comment.