From 5dc7fc15f343f16d077ec44e834c042e8661dc0c Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 27 Dec 2015 22:30:20 +0100 Subject: katara: taffybar patch --- machines/profpatsch/katara.nix | 4 +-- machines/profpatsch/pkgs.nix | 11 ++++++ machines/profpatsch/taffybar.patch | 71 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 machines/profpatsch/taffybar.patch (limited to 'machines') diff --git a/machines/profpatsch/katara.nix b/machines/profpatsch/katara.nix index 63ebdaa9..aeaf10d3 100644 --- a/machines/profpatsch/katara.nix +++ b/machines/profpatsch/katara.nix @@ -100,7 +100,7 @@ in { libnotify # notification library lxappearance # GTK theme chooser xbindkeys # keybinding manager - taffybar # status bar + myPkgs.taffybar # status bar ]; guiPkgs = [ gnome3.adwaita-icon-theme @@ -159,7 +159,7 @@ in { gtk frpnow-gtk frpnow-gloss - taffybar.env + ])) ++ # other packages that I use sometimes in a shell diff --git a/machines/profpatsch/pkgs.nix b/machines/profpatsch/pkgs.nix index ff6a2280..ef0a2f3f 100644 --- a/machines/profpatsch/pkgs.nix +++ b/machines/profpatsch/pkgs.nix @@ -11,4 +11,15 @@ with pkgs; offlineimap = addRuntimeDeps offlineimap [ pythonPackages.pygpgme ]; + taffybar = taffybar.override { + ghcWithPackages = (haskellPackages.override { + overrides = _: super: { + taffybar = super.taffybar.overrideDerivation (old: { + name = old.name + "foo"; + patches = (old.patches or []) ++ [ ./taffybar.patch ]; + }); + }; + }).ghcWithPackages; + }; + } diff --git a/machines/profpatsch/taffybar.patch b/machines/profpatsch/taffybar.patch new file mode 100644 index 00000000..a93fca1a --- /dev/null +++ b/machines/profpatsch/taffybar.patch @@ -0,0 +1,71 @@ +diff --git a/src/System/Taffybar/Battery.hs b/src/System/Taffybar/Battery.hs +index 5335eff..32c7efa 100644 +--- a/src/System/Taffybar/Battery.hs ++++ b/src/System/Taffybar/Battery.hs +@@ -9,6 +9,7 @@ + -- more advanced features could be supported if there is interest. + module System.Taffybar.Battery ( + batteryBarNew, ++ batteryIconNew, + textBatteryNew, + defaultBatteryConfig + ) where +@@ -108,30 +109,22 @@ defaultBatteryConfig = + | pct < 0.9 = (0.5, 0.5, 0.5) + | otherwise = (0, 1, 0) + +--- | A fancy graphical battery widget that represents the current +--- charge as a colored vertical bar. There is also a textual +--- percentage readout next to the bar. ++-- | + batteryBarNew :: BarConfig -- ^ Configuration options for the bar display +- -> Double -- ^ Polling period in seconds + -> IO Widget +-batteryBarNew battCfg pollSeconds = do ++batteryBarNew battCfg = do + battCtxt <- batteryContextNew +- case battCtxt of +- Nothing -> do +- let lbl :: Maybe String +- lbl = Just "No battery" +- labelNew lbl >>= return . toWidget +- Just ctxt -> do +- -- This is currently pretty inefficient - each poll period it +- -- queries the battery twice (once for the label and once for +- -- the bar). +- -- +- -- Converting it to combine the two shouldn't be hard. +- b <- hBoxNew False 1 +- txt <- textBatteryNew "$percentage$%" pollSeconds +- r <- newIORef ctxt +- bar <- pollingBarNew battCfg pollSeconds (battPct r) +- boxPackStart b bar PackNatural 0 +- boxPackStart b txt PackNatural 0 +- widgetShowAll b +- return (toWidget b) ++ let noBat = toWidget <$> labelNew (Just "No battery" :: Maybe String) ++ maybe noBat (batteryIconNew battCfg) battCtxt ++ ++-- | A fancy graphical battery widget that represents the current ++-- charge as a colored vertical bar. ++batteryIconNew :: BarConfig ++ -> BatteryContext ++ -> IO Widget ++batteryIconNew cfg ctxt = do ++ icon <- pollingBarNew cfg pollSeconds . battPct =<< newIORef ctxt ++ widgetShowAll icon ++ return icon ++ where ++ pollSeconds = 5 +diff --git a/src/System/Taffybar/Widgets/PollingBar.hs b/src/System/Taffybar/Widgets/PollingBar.hs +index d30adaf..01f161c 100644 +--- a/src/System/Taffybar/Widgets/PollingBar.hs ++++ b/src/System/Taffybar/Widgets/PollingBar.hs +@@ -16,6 +16,7 @@ import Control.Monad ( forever ) + import Graphics.UI.Gtk + + import System.Taffybar.Widgets.VerticalBar ++import Debug.Trace + + pollingBarNew :: BarConfig -> Double -> IO Double -> IO Widget + pollingBarNew cfg pollSeconds action = do -- cgit 1.4.1