forked from xtonousou/xfce4-genmon-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datetime-panel.sh
executable file
·43 lines (36 loc) · 1.14 KB
/
datetime-panel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Dependencies: bash>=3.2, coreutils, file, gawk, procps-ng
# Makes the script more portable
readonly DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Optional icon to display before the text
# Insert the absolute path of the icon
# Recommended size is 24x24 px
if [ "$(LC_ALL=en_US.UTF-8 date +%d%m)" -eq 2604 ]; then # birthday, 2604 stands for April 26
readonly ICON="${DIR}/icons/datetime/cake-variant.png"
elif [ "$(LC_ALL=en_US.UTF-8 date +%H%M)" -eq 0420 ] \
|| [ "$(LC_ALL=en_US.UTF-8 date +%H%M)" -eq 1620 ] \
|| [ "$(LC_ALL=en_US.UTF-8 date +%d%m)" -eq 2004 ]; then # heyy that's pretty good
readonly ICON="${DIR}/icons/datetime/weed.png"
else
readonly ICON="${DIR}/icons/datetime/clock.png"
fi
# Calculate datetime values
readonly TIME=$(LC_ALL=en_US.UTF-8 date +%T)
readonly DATE=$(LC_ALL=en_US.UTF-8 date +%A\ %d\ %B\ %Y)
# Panel
if [[ $(file -b "${ICON}") =~ PNG|SVG ]]; then
INFO="<img>${ICON}</img>"
INFO+="<txt>"
else
INFO="<txt>"
fi
INFO+="${TIME}"
INFO+="</txt>"
# Tooltip
MORE_INFO="<tool>"
MORE_INFO+="${DATE}"
MORE_INFO+="</tool>"
# Panel Print
echo -e "${INFO}"
# Tooltip Print
echo -e "${MORE_INFO}"