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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/bin/python
# kinda minimal lemonbar script by Vidhu Kant Sharma
# for herbstluftwm
# needs roboto, foboto nerd and adobe hans sans jp fonts
import datetime
import time
import os
day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday','Sunday'] # to make day names more readable
tag_names = {
'1':'一',
'2':'二',
'3':'三',
'4':'四',
'5':'五',
'6':'六',
'7':'七',
'8':'八',
'9':'九',
'0':'十'
}
# decoration variables
def getTags():
tags = os.popen("herbstclient tag_status").read().split() # get tags in a list
for i in range(len(tags)):
tag = tags[i]
if tag[0] == ':':
tags[i] = ' ' + tag_names[tag[1]] + ' ' # format occupied tags
elif tag[0] == '#':
tags[i] = '%{F#6c71c4}%{B#d33682}%{F-} ' + tag_names[tag[1]] + '%{F#d33682} %{B#268bd2}%{F-}' # format active tag
else:
tags[i] = '%{F#443837} ' + tag_names[tag[1]] + '%{F-} ' # format other tags
return '%{A4:NEXT:}%{A5:PREV:}%{B#6c71c4} ' + ' '.join((str(x) for x in tags)) + '%{B-}' + '%{F#268bd2}%{F-}%{A}%{A}' # return formatted list in a cleaner form
def getTime():
date = datetime.datetime.today().strftime("%d/%m") # date in DD/MM format
day_raw = datetime.datetime.today().weekday() # get number of day
day = "(" + day_name[day_raw] + ")" # day but in a more readable form
time = datetime.datetime.now().strftime("%H:%M") # time in H:M format
return '%{F#CB4B16}%{F-}%{B#CB4B16} ' + date + day + ' ' + time + ' %{B-}'
def sleepNotifier():
if int(datetime.datetime.now().strftime("%M")) < 6:
return "%{c}%{F#171520}%{B#dc322f} Go to sleep! %{B-}%{F-}"
else:
return ""
while True:
time.sleep(0.3)
output = getTags() + '%{r}' + getTime() + sleepNotifier()
os.system("echo '" + output + "'")
|