summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-02-27 12:23:28 -0700
committerDavid Luevano Alvarado <55825613+luevano@users.noreply.github.com>2020-02-27 12:23:28 -0700
commit372af894faf5ecefacea0631a04f9f2f9a260e07 (patch)
treed767b9a1b1d095cd8267b591f6fe87f1b05d4608 /.local
parent688b3306f22d938fa3d11342c05396bdc9512e6b (diff)
Fix calendar blocklet
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/blocks/calendar55
1 files changed, 27 insertions, 28 deletions
diff --git a/.local/bin/blocks/calendar b/.local/bin/blocks/calendar
index fa9c805..63b43fc 100755
--- a/.local/bin/blocks/calendar
+++ b/.local/bin/blocks/calendar
@@ -1,41 +1,40 @@
-#!/bin/sh
+#!/bin/bash
-WIDTH=${WIDTH:-200}
-HEIGHT=${HEIGHT:-200}
+LABEL=${LABEL:"+"}
DATEFMT=${DATEFMT:-"+%a %d.%m.%Y %H:%M:%S"}
SHORTFMT=${SHORTFMT:-"+%H:%M:%S"}
+WIDTH=${WIDTH:-200}
+HEIGHT=${HEIGHT:-200}
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
+ 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
- # The size is hardcoded for a 1080p monitor.
- posX=$((1899 - $WIDTH))
- posY=$((35))
+case "$BLOCK_BUTTON" in 1)
+ # Position of the upper left corner of the popup.
+ posX=$(($BLOCK_X - $WIDTH/2))
+ posY=$(($BLOCK_Y + 20))
i3-msg -q "exec yad --calendar \
- --width=$WIDTH --height=$HEIGHT \
- --undecorated --fixed \
- --close-on-unfocus --no-buttons \
- --posx=$posX --posy=$posY \
- > /dev/null"
+ --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")"