[taffybar] A whole bunch of shit

This commit is contained in:
Ivan Malison 2017-10-13 22:09:08 -07:00
parent 7ffa5a67d0
commit 9934e79697
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
2 changed files with 30 additions and 44 deletions

@ -1 +1 @@
Subproject commit 1c1a183585689b655e09ce8f4a78b281ad463981 Subproject commit 7a909e878861e3ee2c6d5a73928858e486293657

View File

@ -58,7 +58,7 @@ getFullWorkspaceNames = go <$> readAsListOfString Nothing "_NET_DESKTOP_FULL_NAM
where go = zip [WSIdx i | i <- [0..]] where go = zip [WSIdx i | i <- [0..]]
workspaceNamesLabelSetter workspace = do workspaceNamesLabelSetter workspace = do
fullNames <- liftX11 getFullWorkspaceNames fullNames <- liftX11Def [] getFullWorkspaceNames
return $ fromMaybe "" $ lookup (workspaceIdx workspace) fullNames return $ fromMaybe "" $ lookup (workspaceIdx workspace) fullNames
mem :: IO Gtk.Widget mem :: IO Gtk.Widget
@ -126,30 +126,29 @@ getInterfaces = do
return $ splitOn "\n" output return $ splitOn "\n" output
main = do main = do
monEither <-
(try $ getEnv "TAFFYBAR_MONITOR") :: IO (Either SomeException String)
interfaceNames <- getInterfaces interfaceNames <- getInterfaces
homeDirectory <- getHomeDirectory homeDirectory <- getHomeDirectory
let resourcesDirectory = homeDirectory </> ".lib" </> "resources" let resourcesDirectory = homeDirectory </> ".lib" </> "resources"
inResourcesDirectory file = resourcesDirectory </> file inResourcesDirectory file = resourcesDirectory </> file
highContrastDirectory = "/" </> "usr" </> "share" </> "icons" </> "HighContrast" </> "256x256" highContrastDirectory =
inHighContrastDirectory file = (highContrastDirectory </> file) "/" </> "usr" </> "share" </> "icons" </> "HighContrast" </> "256x256"
getWorkspacePixBuf size Workspace { workspaceIdx = WSIdx wsId } = inHighContrastDirectory file = highContrastDirectory </> file
getWorkspacePixBuf size Workspace {workspaceIdx = WSIdx wsId} =
pixBufFromFile size . inHighContrastDirectory <$> pixBufFromFile size . inHighContrastDirectory <$>
case wsId + 1 of case wsId + 1 of
1 -> Just $ "apps" </> "utilities-terminal.png" 1 -> Just $ "apps" </> "utilities-terminal.png"
2 -> Just $ "emblems" </> "emblem-documents.png" 2 -> Just $ "emblems" </> "emblem-documents.png"
3 -> Just $ "actions" </> "bookmark-add.png" 3 -> Just $ "actions" </> "bookmark-add.png"
4 -> Just $ "devices" </> "video-display.png" 4 -> Just $ "devices" </> "video-display.png"
_ -> Nothing _ -> Nothing
buildConstantIconController :: ControllerConstructor buildConstantIconController :: ControllerConstructor
buildConstantIconController ws = do buildConstantIconController ws = do
cfg <- asks hudConfig cfg <- asks hudConfig
lift $ do lift $ do
img <- Gtk.imageNew img <- Gtk.imageNew
pb <- sequence $ getWorkspacePixBuf (windowIconSize cfg) ws pb <- sequence $ getWorkspacePixBuf (windowIconSize cfg) ws
setImage (windowIconSize cfg) img pb setImage (windowIconSize cfg) img pb
return $ WWC ConstantIconController { cicImage = img } return $ WWC ConstantIconController {cicImage = img}
makeIcon = return . IIFilePath . inResourcesDirectory makeIcon = return . IIFilePath . inResourcesDirectory
myGetIconInfo w@WindowData {windowTitle = title, windowClass = klass} myGetIconInfo w@WindowData {windowTitle = title, windowClass = klass}
| "URxvt" `isInfixOf` klass = makeIcon "urxvt.png" | "URxvt" `isInfixOf` klass = makeIcon "urxvt.png"
@ -164,13 +163,6 @@ main = do
case res of case res of
IINone -> IIFilePath $ inResourcesDirectory "exe-icon.png" IINone -> IIFilePath $ inResourcesDirectory "exe-icon.png"
_ -> res _ -> res
(_, monNumber) =
case monEither of
Left _ -> (allMonitors, 0)
Right monString ->
case readMaybe monString of
Nothing -> (allMonitors, 0)
Just num -> (useMonitorNumber, num)
cpuCfg = cpuCfg =
defaultGraphConfig defaultGraphConfig
{ graphDataColors = [(0, 1, 0, 1), (1, 0, 1, 0.5)] { graphDataColors = [(0, 1, 0, 1), (1, 0, 1, 0.5)]
@ -179,14 +171,6 @@ main = do
clock = textClockNew Nothing "%a %b %_d %r" 1 clock = textClockNew Nothing "%a %b %_d %r" 1
mpris = mpris2New mpris = mpris2New
cpu = pollingGraphNew cpuCfg 0.5 cpuCallback cpu = pollingGraphNew cpuCfg 0.5 cpuCallback
tray = do
theTray <- systrayNew
cont <- Gtk.eventBoxNew
Gtk.containerAdd cont theTray
Gtk.widgetSetName cont "Taffytray"
Gtk.widgetSetName theTray "Taffytray"
Gtk.widgetShowAll cont
return $ Gtk.toWidget cont
myHUDConfig = myHUDConfig =
defaultWorkspaceHUDConfig defaultWorkspaceHUDConfig
{ underlineHeight = 3 { underlineHeight = 3
@ -194,12 +178,16 @@ main = do
, minWSWidgetSize = Nothing , minWSWidgetSize = Nothing
, minIcons = 3 , minIcons = 3
, getIconInfo = myGetIconInfo , getIconInfo = myGetIconInfo
, windowIconSize = 25 , windowIconSize = 32
, widgetGap = 0 , widgetGap = 0
, widgetBuilder = buildButtonController $ , widgetBuilder =
buildUnderlineController $ buildButtonController $
buildContentsController buildUnderlineController $
[buildConstantIconController, buildLabelController, buildIconController] buildContentsController
[ buildConstantIconController
, buildLabelController
, buildIconController
]
, showWorkspaceFn = hideEmpty , showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000 , updateRateLimitMicroseconds = 100000
, updateIconsOnTitleChange = True , updateIconsOnTitleChange = True
@ -214,10 +202,9 @@ main = do
pagerConfig = pagerConfig =
defaultPagerConfig defaultPagerConfig
{useImages = True, windowSwitcherFormatter = myFormatEntry} {useImages = True, windowSwitcherFormatter = myFormatEntry}
-- pager = taffyPagerNew pagerConfig
makeUnderline = underlineWidget myHUDConfig makeUnderline = underlineWidget myHUDConfig
pgr <- pagerNew pagerConfig pgr <- pagerNew pagerConfig
tray2 <- movableWidget tray -- tray2 <- movableWidget tray
let hud = buildWorkspaceHUD myHUDConfig pgr let hud = buildWorkspaceHUD myHUDConfig pgr
los = makeUnderline (layoutSwitcherNew pgr) "red" los = makeUnderline (layoutSwitcherNew pgr) "red"
wnd = makeUnderline (windowSwitcherNew pgr) "teal" wnd = makeUnderline (windowSwitcherNew pgr) "teal"
@ -225,16 +212,15 @@ main = do
defaultTaffybarConfig defaultTaffybarConfig
{ startWidgets = [hud, los, wnd] { startWidgets = [hud, los, wnd]
, endWidgets = , endWidgets =
[ makeUnderline tray "yellow" [ makeUnderline systrayNew "yellow"
, makeUnderline clock "teal" , makeUnderline clock "teal"
, makeUnderline mem "blue" , makeUnderline mem "blue"
, makeUnderline cpu "green" , makeUnderline cpu "green"
, makeUnderline netMonitor "yellow" , makeUnderline netMonitor "yellow"
, makeUnderline mpris "red" , makeUnderline mpris "red"
] ]
, monitorNumber = monNumber
, barPosition = Top , barPosition = Top
, barHeight = 50 , barHeight = (underlineHeight myHUDConfig + windowIconSize myHUDConfig) + (2 * (innerPadding myHUDConfig + outerPadding myHUDConfig))
, widgetSpacing = 5 , widgetSpacing = 5
} }
withToggleSupport taffyConfig withToggleSupport taffyConfig