91 lines
2.7 KiB
Haskell
Raw Normal View History

module Main where
2016-09-16 14:11:52 -07:00
2017-02-22 18:15:43 -08:00
import Data.Char (toLower)
2017-03-04 03:42:30 -08:00
import Text.Read
2017-02-22 18:15:43 -08:00
import Data.List
2017-03-04 03:42:30 -08:00
import Data.Maybe
2017-02-22 18:15:43 -08:00
import System.Directory
import System.FilePath.Posix
import System.Information.CPU
import System.Information.Memory
import System.Taffybar
import System.Taffybar.IconImages
2017-01-31 23:19:34 -08:00
import System.Taffybar.MPRIS2
import System.Taffybar.Pager
import System.Taffybar.SimpleClock
2016-09-16 14:11:52 -07:00
import System.Taffybar.Systray
import System.Taffybar.TaffyPager
import System.Taffybar.Widgets.PollingGraph
import System.Taffybar.WorkspaceHUD
2017-03-04 03:42:30 -08:00
import System.Environment
2016-09-16 14:11:52 -07:00
memCallback = do
mi <- parseMeminfo
return [memoryUsedRatio mi]
cpuCallback = do
(_, systemLoad, totalLoad) <- cpuLoad
2016-09-16 14:11:52 -07:00
return [totalLoad, systemLoad]
2017-02-22 18:15:43 -08:00
resourcesDirectory file = ("/home" </> "imalison" </> ".lib" </> "resources" </> file)
2017-02-22 18:15:43 -08:00
fallbackIcons _ klass
| isInfixOf "URxvt" klass = IIFilePath $ resourcesDirectory "urxvt.png"
2017-03-04 03:45:10 -08:00
| isInfixOf "Kodi" klass = IIFilePath $ resourcesDirectory "kodi.png"
2017-02-22 18:15:43 -08:00
| otherwise = IIColor $ (0xFF, 0xFF, 0, 0xFF)
myGetIconInfo =
2017-02-22 18:15:43 -08:00
windowTitleClassIconGetter False fallbackIcons
2016-09-16 14:11:52 -07:00
main = do
2017-03-04 03:42:30 -08:00
monString <- getEnv "TAFFYBAR_MONITOR"
let monitorNumber = fromMaybe 1 $ readMaybe monString
let memCfg =
defaultGraphConfig
{graphDataColors = [(1, 0, 0, 1)], graphLabel = Just "mem"}
cpuCfg =
defaultGraphConfig
{ graphDataColors = [(0, 1, 0, 1), (1, 0, 1, 0.5)]
, graphLabel = Just "cpu"
}
2017-02-01 15:58:13 -08:00
let clock = textClockNew Nothing "%a %b %_d %r" 1
pagerConfig = defaultPagerConfig {useImages = True}
2016-09-19 12:08:25 -07:00
mpris = mpris2New
2016-09-16 14:11:52 -07:00
mem = pollingGraphNew memCfg 1 memCallback
cpu = pollingGraphNew cpuCfg 0.5 cpuCallback
tray = systrayNew
hudConfig =
defaultWorkspaceHUDConfig
{ underlineHeight = 3
2017-03-04 03:42:30 -08:00
, underlinePadding = 0
, minWSWidgetSize = Nothing
, minIcons = 3
, getIconInfo = myGetIconInfo
, windowIconSize = 32
, widgetGap = 0
-- , widgetBuilder = buildBorderButtonController
, showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000
, updateIconsOnTitleChange = True
, updateOnWMIconChange = True
, debugMode = True
2017-03-04 03:45:10 -08:00
, redrawIconsOnStateChange = True
}
hudPagerConfig = hudFromPagerConfig pagerConfig
2017-02-16 16:24:38 -08:00
hud = taffyPagerHUDNew pagerConfig hudConfig
pager = taffyPagerNew pagerConfig
defaultTaffybar
defaultTaffybarConfig
{ startWidgets = [hud]
, endWidgets = [tray, clock, mem, cpu, mpris]
2017-03-04 03:42:30 -08:00
, monitorNumber = monitorNumber
, monitorFilter = allMonitors
, barPosition = Top
, barHeight = 40
}
2016-09-16 14:11:52 -07:00
-- Local Variables:
-- flycheck-ghc-args: ("-Wno-missing-signatures")
-- End: