-
Notifications
You must be signed in to change notification settings - Fork 0
/
taffybar.hs
75 lines (60 loc) · 2.21 KB
/
taffybar.hs
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
import System.Environment (lookupEnv)
import Data.Maybe (fromMaybe)
import System.Taffybar
import System.Taffybar.TaffyPager
import System.Taffybar.Pager
import System.Taffybar.WindowSwitcher
import System.Taffybar.WorkspaceSwitcher
import System.Taffybar.Battery
import System.Taffybar.SimpleClock
import System.Taffybar.Systray
import System.Taffybar.MPRIS2
import System.Taffybar.Widgets.PollingBar
import System.Taffybar.Widgets.PollingGraph
import System.Information.Memory
import System.Information.CPU
import System.Taffybar.Volume
import Control.Applicative ((<$>))
pagerCfg = defaultPagerConfig
{ emptyWorkspace = colorize "#6b6b6b" "" . escape
, activeWorkspace = colorize "#429942" "" . escape . wrap "<" ">"
}
main = do
scr <- maybe 0 read <$> lookupEnv "TAFFY_SCREEN"
pager <- pagerNew pagerCfg
let wss = wspaceSwitcherNew pager
wnd = windowSwitcherNew pager
clock = textClockNew Nothing "<span fgcolor='orange'>%a %b %_d %H:%M</span>" 1
mpris = mpris2New
battery = textBatteryNew "$percentage$%/$time$" 60
tray = systrayNew
vol = volumeW
mem = pollingGraphNew memCfg 1 memCallback
where
memCallback = do
mi <- parseMeminfo
return [memoryUsedRatio mi]
memCfg = defaultGraphConfig
{ graphDataColors = [(1, 0, 0, 1)]
, graphLabel = Nothing
, graphDirection = RIGHT_TO_LEFT
}
cpu = pollingGraphNew cpuCfg 1 cpuCallback
where
cpuCallback = do
(_, _, totalLoad) <- cpuLoad
return [totalLoad]
cpuCfg = defaultGraphConfig
{ graphDataColors = [(0, 1, 0, 1)]
, graphLabel = Nothing
, graphDirection = RIGHT_TO_LEFT
}
defaultTaffybar defaultTaffybarConfig
{ barHeight = 20
, monitorNumber = scr
-- , startWidgets = [wss, wnd]
, startWidgets = [wss]
, endWidgets = reverse $ if scr == 0
then [mpris, vol, cpu, mem, battery, clock, tray]
else [clock]
}