[taffybar] GithubNotifications

This commit is contained in:
Ivan Malison 2018-04-27 17:36:32 -07:00
parent 6875fe986f
commit 887e0a77f3
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
5 changed files with 49 additions and 51 deletions

View File

@ -15,10 +15,12 @@ executable imalison-taffybar
main-is: taffybar.hs main-is: taffybar.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base build-depends: base
, bytestring
, containers , containers
, directory , directory
, filepath , filepath
, gtk-strut , gtk-strut
, github
, gi-gtk , gi-gtk
, glib , glib
, gtk3>=0.14.8 , gtk3>=0.14.8
@ -30,6 +32,7 @@ executable imalison-taffybar
, split , split
, taffybar , taffybar
, xmonad-contrib>=0.13 , xmonad-contrib>=0.13
, xmonad>=0.13
, X11>=1.8 , X11>=1.8
default-language: Haskell2010 default-language: Haskell2010

View File

@ -14,6 +14,8 @@ packages:
# extra-dep: true # extra-dep: true
# - location: ../../../../Projects/gtk-sni-tray # - location: ../../../../Projects/gtk-sni-tray
# extra-dep: true # extra-dep: true
- location: '../../../../Projects/github'
extra-dep: true
extra-deps: extra-deps:
- X11-xft-0.3.1 - X11-xft-0.3.1
- dbus-1.0.1 - dbus-1.0.1
@ -27,7 +29,7 @@ extra-deps:
- gi-pango-1.0.16 - gi-pango-1.0.16
- gi-xlib-2.0.2 - gi-xlib-2.0.2
- gio-0.13.4.1 - gio-0.13.4.1
- gtk-sni-tray-0.1.0.0 - gtk-sni-tray-0.1.1.0
- gtk-strut-0.1.2.0 - gtk-strut-0.1.2.0
- gtk-traymanager-1.0.1 - gtk-traymanager-1.0.1
- gtk3-0.14.9 - gtk3-0.14.9
@ -40,4 +42,3 @@ extra-deps:
- time-units-1.0.0 - time-units-1.0.0
- xml-helpers-1.0.0 - xml-helpers-1.0.0
resolver: lts-11.5 resolver: lts-11.5
allow-newer: true

@ -1 +1 @@
Subproject commit 15b7f8c40ef865b3aeb4d8c1373bf01c400afa3e Subproject commit 553c634f36cc66c9d789d789ee9e4e2f81d5e6d5

View File

@ -5,13 +5,16 @@
@define-color font-color #FFFFFF; @define-color font-color #FFFFFF;
.Contents { .Contents {
border-radius: 5px;
padding: 3px; padding: 3px;
transition: border-color .5s;
border-radius: 5px;
border-style: solid;
border-width: 1;
border-color: rgba(1.0, 1.0, 1.0, 0.0);
} }
.Active .Contents, .Visible .Contents { .Active .Contents, .Visible .Contents {
background-color: #000000; border-color: #FFFFFF;
transition: background-color 1s;
} }
.InnerPad { .InnerPad {
@ -25,13 +28,15 @@
} }
.IconContainer { .IconContainer {
transition: background-color .5s; transition: border-color .5s;
border-radius: 5px; border-radius: 0px;
border-bottom: solid;
border-width: 1;
border-color: rgba(1.0, 1.0, 1.0, 0.0);
} }
.IconContainer.Active { .IconContainer.Active {
transition: background-color .5s; border-color: #FFFFFF;
background-color: @active-window-color;
} }
.IconContainer.Urgent { .IconContainer.Urgent {
@ -70,6 +75,12 @@
padding: 20px; padding: 20px;
} }
.TaffyBox {
border-bottom: solid;
border-width: 1;
border-color: #FFFFFF;
}
.Taffybar * { .Taffybar * {
font-family: "Fira Sans", sans-serif; font-family: "Fira Sans", sans-serif;
font-size: 12pt; font-size: 12pt;

View File

@ -6,6 +6,7 @@ import Control.Exception.Base
import Control.Monad import Control.Monad
import Control.Monad.Reader import Control.Monad.Reader
import Control.Monad.Trans import Control.Monad.Trans
import qualified Data.ByteString.Char8 as BS
import Data.GI.Base import Data.GI.Base
import Data.GI.Base.ManagedPtr import Data.GI.Base.ManagedPtr
import Data.List import Data.List
@ -16,6 +17,7 @@ import Debug.Trace
import Foreign.ForeignPtr import Foreign.ForeignPtr
import Foreign.Ptr import Foreign.Ptr
import qualified GI.Gtk as GI import qualified GI.Gtk as GI
import qualified GitHub.Auth as Auth
import qualified "gtk3" Graphics.UI.Gtk as Gtk import qualified "gtk3" Graphics.UI.Gtk as Gtk
import qualified "gtk3" Graphics.UI.Gtk.Abstract.Widget as W import qualified "gtk3" Graphics.UI.Gtk.Abstract.Widget as W
import qualified "gtk3" Graphics.UI.Gtk.Layout.Table as T import qualified "gtk3" Graphics.UI.Gtk.Layout.Table as T
@ -30,6 +32,7 @@ import System.Log.Handler.Simple
import System.Log.Logger import System.Log.Logger
import System.Process import System.Process
import System.Taffybar import System.Taffybar
import System.Taffybar.Auth
import System.Taffybar.DBus.Toggle import System.Taffybar.DBus.Toggle
import System.Taffybar.IconImages import System.Taffybar.IconImages
import System.Taffybar.Information.CPU import System.Taffybar.Information.CPU
@ -44,16 +47,6 @@ import Text.Printf
import Text.Read hiding (lift) import Text.Read hiding (lift)
import Unsafe.Coerce import Unsafe.Coerce
newtype ConstantIconController = ConstantIconController { cicImage :: Gtk.Image }
instance WorkspaceWidgetController ConstantIconController where
updateWidget cic _ = return cic
getWidget = Gtk.toWidget . cicImage
instance WorkspaceWidgetController Gtk.Widget where
updateWidget w _ = return w
getWidget w = w
makeContents waction klass = do makeContents waction klass = do
widget <- waction widget <- waction
liftIO $ do liftIO $ do
@ -72,7 +65,9 @@ myGraphConfig =
memCfg = memCfg =
myGraphConfig myGraphConfig
{graphDataColors = [(0.129, 0.588, 0.953, 1)], graphLabel = Just "mem"} { graphDataColors = [(0.129, 0.588, 0.953, 1)]
, graphLabel = Just "mem"
}
memCallback :: IO [Double] memCallback :: IO [Double]
memCallback = do memCallback = do
@ -87,18 +82,6 @@ workspaceNamesLabelSetter workspace =
fromMaybe "" . lookup (workspaceIdx workspace) <$> fromMaybe "" . lookup (workspaceIdx workspace) <$>
liftX11Def [] getFullWorkspaceNames liftX11Def [] getFullWorkspaceNames
-- mem :: IO Gtk.Widget
-- mem = do
-- ebox <- Gtk.eventBoxNew
-- btn <- pollingGraphNew memCfg 1 $ memCallback $ Gtk.toWidget ebox
-- Gtk.containerAdd ebox btn
-- _ <- Gtk.on ebox Gtk.buttonPressEvent systemEvents
-- Gtk.widgetShowAll ebox
-- return $ Gtk.toWidget ebox
systemEvents :: Gtk.EventM Gtk.EButton Bool
systemEvents = return True
cpuCallback = do cpuCallback = do
(_, systemLoad, totalLoad) <- cpuLoad (_, systemLoad, totalLoad) <- cpuLoad
return [totalLoad, systemLoad] return [totalLoad, systemLoad]
@ -146,6 +129,12 @@ logDebug = do
infoLogger <- getLogger "System.Information" infoLogger <- getLogger "System.Information"
saveGlobalLogger $ setLevel DEBUG infoLogger saveGlobalLogger $ setLevel DEBUG infoLogger
github = do
Right (token, _) <- passGet "github-token"
githubNotificationsNew GitHubConfig { ghAuth = Auth.OAuth $ BS.pack token
, ghIcon = undefined
}
main = do main = do
interfaceNames <- getInterfaces interfaceNames <- getInterfaces
homeDirectory <- getHomeDirectory homeDirectory <- getHomeDirectory
@ -162,14 +151,14 @@ main = do
-- 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"
@ -202,14 +191,6 @@ main = do
, getIconInfo = myGetIconInfo , getIconInfo = myGetIconInfo
, windowIconSize = 30 , windowIconSize = 30
, widgetGap = 0 , widgetGap = 0
-- , widgetBuilder =
-- buildButtonController $
-- buildUnderlineController $
-- buildContentsController
-- [ buildConstantIconController
-- , buildLabelController
-- , buildIconController
-- ]
, showWorkspaceFn = hideEmpty , showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000 , updateRateLimitMicroseconds = 100000
, labelSetter = workspaceNamesLabelSetter , labelSetter = workspaceNamesLabelSetter
@ -228,10 +209,12 @@ main = do
, makeContents cpu "Cpu" , makeContents cpu "Cpu"
, makeContents mem "Cpu" , makeContents mem "Cpu"
, makeContents netMonitor "Cpu" , makeContents netMonitor "Cpu"
, mpris , makeContents (fsMonitorNew 60 ["/dev/sdd2"]) "Cpu"
, mpris >>= buildPadBox
, github >>= buildPadBox
] ]
, barPosition = Top , barPosition = Top
, barPadding = 5 , barPadding = 0
, barHeight = (underlineHeight myWorkspacesConfig + windowIconSize myWorkspacesConfig + 15) , barHeight = (underlineHeight myWorkspacesConfig + windowIconSize myWorkspacesConfig + 15)
, widgetSpacing = 0 , widgetSpacing = 0
} }