Skip to content

Instantly share code, notes, and snippets.

@arnsholt
Created November 8, 2015 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnsholt/febd08ef28cc0e97744b to your computer and use it in GitHub Desktop.
Save arnsholt/febd08ef28cc0e97744b to your computer and use it in GitHub Desktop.
import Graphics.UI.Gtk as Gtk
import System.Taffybar
import System.Taffybar.Battery
import System.Taffybar.NetMonitor
import System.Taffybar.SimpleClock
import System.Taffybar.Systray
import System.Taffybar.Pager
import System.Taffybar.TaffyPager
import System.Taffybar.Widgets.PollingGraph
import System.Taffybar.Widgets.PollingLabel
import System.Information.CPU
import System.Information.Memory
cpuCallback = do
(_, systemLoad, totalLoad) <- cpuLoad
return [ totalLoad, systemLoad ]
-- With code liberally snarfed from System.Taffybar.Text.MemoryMonitor:
mem = do
label <- pollingLabelNew "Mem" 0.5 callback
Gtk.widgetShowAll label
return label
where
callback = do
info <- parseMeminfo
return $ "Mem: " ++ (show . truncate $ 100*memoryUsedRatio info) ++ "%"
-- xmobar widgets: XMonad crap || network | cpu | memory | battery | time
main = do
let cpuCfg = defaultGraphConfig { graphDataColors = [ (0, 1, 0, 1), (1, 0, 1, 0.5)]
, graphLabel = Nothing
}
batt = batteryBarNew defaultBatteryConfig 0.5
clock = textClockNew Nothing "%A %B %d, %Y" 1
cpu = pollingGraphNew cpuCfg 0.5 cpuCallback
log = taffyPagerNew $ defaultPagerConfig { activeWorkspace = wrap "[" "]" . escape
, emptyWorkspace = \_ -> ""
, activeWindow = shorten 100
, widgetSep = " | "
}
net = netMonitorNew 0.5 "wlan0"
tray = systrayNew
defaultTaffybar defaultTaffybarConfig { startWidgets = [log]
, endWidgets = reverse [net, cpu, mem, batt, clock, tray]
, barHeight = 20
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment