[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
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, bytestring
, containers
, directory
, filepath
, gtk-strut
, github
, gi-gtk
, glib
, gtk3>=0.14.8
@ -30,6 +32,7 @@ executable imalison-taffybar
, split
, taffybar
, xmonad-contrib>=0.13
, xmonad>=0.13
, X11>=1.8
default-language: Haskell2010

View File

@ -14,6 +14,8 @@ packages:
# extra-dep: true
# - location: ../../../../Projects/gtk-sni-tray
# extra-dep: true
- location: '../../../../Projects/github'
extra-dep: true
extra-deps:
- X11-xft-0.3.1
- dbus-1.0.1
@ -27,7 +29,7 @@ extra-deps:
- gi-pango-1.0.16
- gi-xlib-2.0.2
- 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-traymanager-1.0.1
- gtk3-0.14.9
@ -40,4 +42,3 @@ extra-deps:
- time-units-1.0.0
- xml-helpers-1.0.0
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;
.Contents {
border-radius: 5px;
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 {
background-color: #000000;
transition: background-color 1s;
border-color: #FFFFFF;
}
.InnerPad {
@ -25,13 +28,15 @@
}
.IconContainer {
transition: background-color .5s;
border-radius: 5px;
transition: border-color .5s;
border-radius: 0px;
border-bottom: solid;
border-width: 1;
border-color: rgba(1.0, 1.0, 1.0, 0.0);
}
.IconContainer.Active {
transition: background-color .5s;
background-color: @active-window-color;
border-color: #FFFFFF;
}
.IconContainer.Urgent {
@ -70,6 +75,12 @@
padding: 20px;
}
.TaffyBox {
border-bottom: solid;
border-width: 1;
border-color: #FFFFFF;
}
.Taffybar * {
font-family: "Fira Sans", sans-serif;
font-size: 12pt;

View File

@ -6,6 +6,7 @@ import Control.Exception.Base
import Control.Monad
import Control.Monad.Reader
import Control.Monad.Trans
import qualified Data.ByteString.Char8 as BS
import Data.GI.Base
import Data.GI.Base.ManagedPtr
import Data.List
@ -16,6 +17,7 @@ import Debug.Trace
import Foreign.ForeignPtr
import Foreign.Ptr
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.Abstract.Widget as W
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.Process
import System.Taffybar
import System.Taffybar.Auth
import System.Taffybar.DBus.Toggle
import System.Taffybar.IconImages
import System.Taffybar.Information.CPU
@ -44,16 +47,6 @@ import Text.Printf
import Text.Read hiding (lift)
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
widget <- waction
liftIO $ do
@ -72,7 +65,9 @@ myGraphConfig =
memCfg =
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 = do
@ -87,18 +82,6 @@ workspaceNamesLabelSetter workspace =
fromMaybe "" . lookup (workspaceIdx workspace) <$>
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
(_, systemLoad, totalLoad) <- cpuLoad
return [totalLoad, systemLoad]
@ -146,6 +129,12 @@ logDebug = do
infoLogger <- getLogger "System.Information"
saveGlobalLogger $ setLevel DEBUG infoLogger
github = do
Right (token, _) <- passGet "github-token"
githubNotificationsNew GitHubConfig { ghAuth = Auth.OAuth $ BS.pack token
, ghIcon = undefined
}
main = do
interfaceNames <- getInterfaces
homeDirectory <- getHomeDirectory
@ -162,14 +151,14 @@ main = do
-- 3 -> Just $ "actions" </> "bookmark-add.png"
-- 4 -> Just $ "devices" </> "video-display.png"
_ -> Nothing
buildConstantIconController :: ControllerConstructor
buildConstantIconController ws = do
cfg <- asks hudConfig
lift $ do
img <- Gtk.imageNew
pb <- sequence $ getWorkspacePixBuf (windowIconSize cfg) ws
setImage (windowIconSize cfg) img pb
return $ WWC ConstantIconController {cicImage = img}
-- buildConstantIconController :: ControllerConstructor
-- buildConstantIconController ws = do
-- cfg <- asks hudConfig
-- lift $ do
-- img <- Gtk.imageNew
-- pb <- sequence $ getWorkspacePixBuf (windowIconSize cfg) ws
-- setImage (windowIconSize cfg) img pb
-- return $ WWC ConstantIconController {cicImage = img}
makeIcon = return . IIFilePath . inResourcesDirectory
myGetIconInfo w@WindowData {windowTitle = title, windowClass = klass}
| "URxvt" `isInfixOf` klass = makeIcon "urxvt.png"
@ -202,14 +191,6 @@ main = do
, getIconInfo = myGetIconInfo
, windowIconSize = 30
, widgetGap = 0
-- , widgetBuilder =
-- buildButtonController $
-- buildUnderlineController $
-- buildContentsController
-- [ buildConstantIconController
-- , buildLabelController
-- , buildIconController
-- ]
, showWorkspaceFn = hideEmpty
, updateRateLimitMicroseconds = 100000
, labelSetter = workspaceNamesLabelSetter
@ -228,10 +209,12 @@ main = do
, makeContents cpu "Cpu"
, makeContents mem "Cpu"
, makeContents netMonitor "Cpu"
, mpris
, makeContents (fsMonitorNew 60 ["/dev/sdd2"]) "Cpu"
, mpris >>= buildPadBox
, github >>= buildPadBox
]
, barPosition = Top
, barPadding = 5
, barPadding = 0
, barHeight = (underlineHeight myWorkspacesConfig + windowIconSize myWorkspacesConfig + 15)
, widgetSpacing = 0
}