-
Notifications
You must be signed in to change notification settings - Fork 0
/
taffybar.hs.maildir
129 lines (113 loc) · 3.82 KB
/
taffybar.hs.maildir
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import System.Taffybar
import System.Taffybar.Systray
import System.Taffybar.SimpleClock
import System.Taffybar.FreedesktopNotifications
import System.Taffybar.MPRIS2
import System.Taffybar.Battery
import System.Taffybar.Maildir
import System.Taffybar.Pager
import System.Taffybar.TaffyPager
import System.Taffybar.Widgets.PollingBar
import System.Taffybar.Widgets.PollingGraph
import System.Taffybar.Widgets.PollingLabel
import System.Information.Memory
import System.Information.CPU
import System.Information.Battery
import qualified Data.Time.Clock as Clock
import System.Locale
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Display.Image
import Graphics.UI.Gtk.Layout.HBox
import Data.Colour.RGBSpace
import Data.Colour.RGBSpace.HSL
import Data.Time.Format
import Data.Time.LocalTime
memCallback = do
mi <- parseMeminfo
return [memoryUsedRatio mi]
cpuCallback = do
(userLoad, systemLoad, totalLoad) <- cpuLoad
return [totalLoad, systemLoad]
memCfg = defaultGraphConfig
{ graphDataColors = [(22/255, 147/255, 165/255, 1)]
, graphLabel = Nothing
, graphWidth = 30
, graphPadding = 2
, graphBorderColor = (0.247, 0.247, 0.247)
}
cpuCfg = defaultGraphConfig
{ graphDataColors = [(251/255, 184/255, 41/255, 1), (1, 0, 1, 0.5)]
, graphLabel = Nothing
, graphWidth = 30
, graphPadding = 2
, graphBorderColor = (0.247, 0.247, 0.247)
}
batCfg = defaultBatteryConfig
{ barPadding = 2
, barColor = \perc -> let (RGB r g b) = hsl (120 * perc) 1 0.5 in (r, g, b)
, barBorderColor = (0.247, 0.247, 0.247)
, barWidth = 12
}
-- Data.Time.Format doesn't allow customizing the timezone offset,
-- so I'm implementing the clock manually.
-- (I also don't need the pop-up calendar of the default clock widget)
myClock :: IO Widget
myClock = do
z <- getCurrentTimeZone
l <- pollingLabelNew "" 1.0 (callback z)
ebox <- eventBoxNew
containerAdd ebox l
eventBoxSetVisibleWindow ebox False
widgetShowAll ebox
return (toWidget ebox)
where
callback z = do
time <- showFormat z "%a %Y-%m-%d<span fgcolor='grey'>T</span><span fgcolor='yellow'>%H:%M</span>"
os <- offset z
return $ time ++ "<span fgcolor='grey'>" ++ os ++ "</span>"
offset z = do
(x:y:z:xs) <- showFormat z "%z"
return (x:y:z:':':xs)
showFormat z f = return . formatTime defaultTimeLocale f . utcToZonedTime z =<< Clock.getCurrentTime
pad = do
label <- labelNew Nothing
widgetShowAll label
return (toWidget label)
note = notifyAreaNew defaultNotificationConfig
mpris = mpris2New
mem = pollingGraphNew memCfg 4 memCallback
cpu = pollingGraphNew cpuCfg 0.3 cpuCallback
tray = systrayNew
bat = batteryBarNew batCfg 5
mailMain = mailDirNew "<span fgcolor='yellow'>M</span>" "/home/igor/.mail/main/INBOX"
mailGmail = mailDirNew "<span fgcolor='yellow'>G</span>" "/home/igor/.mail/gmail/INBOX"
mailUni = mailDirNew "<span fgcolor='yellow'>U</span>" "/home/igor/.mail/uni/INBOX"
mailCern = mailDirNew "<span fgcolor='yellow'>C</span>" "/home/igor/.mail/cern/INBOX"
myPagerConfig :: PagerConfig
myPagerConfig = PagerConfig
{ activeWindow = escape . shorten 40
, activeLayout = escape
, activeWorkspace = colorize "yellow" "" . escape
, hiddenWorkspace = colorize "light grey" "" . escape
, emptyWorkspace = colorize "grey" "" . escape
, visibleWorkspace = colorize "white" "" . escape
, urgentWorkspace = colorize "red" "" . escape
, widgetSep = " :: "
}
pager = taffyPagerNew myPagerConfig
main = defaultTaffybar defaultTaffybarConfig
{ startWidgets = [ pad, pager ]
, endWidgets = [ pad
, myClock
, mem
, cpu
, bat
, tray
, mailUni
, mailGmail
, mailMain
, mailCern
, mpris
]
, barHeight = 19
}