import System.Taffybar import System.Taffybar.Systray import System.Taffybar.SimpleClock import System.Taffybar.Widgets.PollingGraph import System.Taffybar.Widgets.PollingLabel import System.Information.CPU import System.Taffybar.TaffyPager import System.Taffybar.Pager import System.Taffybar.FreedesktopNotifications cpuCallback :: IO [Double] cpuCallback = do (_, systemLoad, totalLoad) <- cpuLoad return [ totalLoad, systemLoad ] tempGraphConfig :: GraphConfig tempGraphConfig = defaultGraphConfig { graphDataColors = [ (1, 0, 0, 1), (0, 0, 1, 0.75) ] , graphLabel = Just "temp" } graphCallback:: IO [Double] graphCallback = do fan' <- readFile "/proc/acpi/ibm/fan" temp <- readFile "/sys/devices/virtual/thermal/thermal_zone0/temp" let speed' = head $ tail $ lines fan' speed = last $ words speed' speedn = (read speed) :: Int speedd = (fromIntegral speedn) / 4200 let tempn = (read temp) :: Int let tempd = (fromIntegral tempn) / 100000 return [tempd, speedd] fanCallback :: IO String fanCallback = do fan' <- readFile "/proc/acpi/ibm/fan" let speed' = head $ tail $ lines fan' speed = last $ words speed' speedn = (read speed) :: Int if speedn == 0 then (return "---") else (return speed) main :: IO () main = do let cpuCfg = defaultGraphConfig { graphDataColors = [ (0, 1, 0, 1), (1, 0, 1, 0.5)] , graphLabel = Just "cpu" } clock = textClockNew Nothing "%a %b %_d %H:%M" 1 pager = taffyPagerNew defaultPagerConfig { activeWindow = escape , emptyWorkspace = escape } tray = systrayNew fan = pollingLabelNew "" 1 fanCallback cpu = pollingGraphNew cpuCfg 0.5 cpuCallback temp = pollingGraphNew tempGraphConfig 1.0 graphCallback notify = notifyAreaNew defaultNotificationConfig defaultTaffybar defaultTaffybarConfig { startWidgets = [ pager ] , endWidgets = [ clock, tray, cpu, temp, fan, notify ] , barHeight = 24 }