File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed
polybar-scripts/info-timezone Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Script: info-timezone
2
+
3
+ A custom polybar script to switch the timezone of the date displayed.
4
+
5
+ ![ info-timezone] ( screenshots/1.gif )
6
+
7
+
8
+ ## Module
9
+
10
+ ``` ini
11
+ [module/info-timezone]
12
+ type = custom/script
13
+ exec = ~/polybar-scripts/info-timezone.sh
14
+ tail = true
15
+ click-left = kill -USR1 %pid%
16
+ ```
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # Change format here. see `man date` for format controls.
4
+ FORMAT=" %I:%M %p"
5
+
6
+ # Add the timezones of your choice. see `timedatectl list-timezones`.
7
+ set -- " UTC-0" " Australia/Sydney" " Asia/Kolkata" " America/Chicago"
8
+
9
+ TIMEZONES_LENGTH=$#
10
+ current_idx=1
11
+
12
+ print_date () {
13
+ TZ=${current_timezone:? } date +" ${FORMAT} " | echo " ${current_timezone:? } : $( cat -) "
14
+ }
15
+
16
+ update_current_timezone () {
17
+ current_idx=$(( $((current_idx+ 1 )) % $(( "$TIMEZONES_LENGTH "+ 1 )) ))
18
+ if [ $current_idx -lt 1 ]; then
19
+ current_idx=1
20
+ fi
21
+ }
22
+
23
+ click () {
24
+ update_current_timezone
25
+ print_date
26
+ }
27
+
28
+ trap " click" USR1
29
+
30
+ while true ; do
31
+ eval " current_timezone=\$ {$current_idx }"
32
+ print_date current_timezone
33
+ sleep 5 &
34
+ wait
35
+ done
You can’t perform that action at this time.
0 commit comments