diff options
Diffstat (limited to 'accounts/gkleen@sif/taffybar/src/taffybar.hs')
-rw-r--r-- | accounts/gkleen@sif/taffybar/src/taffybar.hs | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/accounts/gkleen@sif/taffybar/src/taffybar.hs b/accounts/gkleen@sif/taffybar/src/taffybar.hs deleted file mode 100644 index 67ee942d..00000000 --- a/accounts/gkleen@sif/taffybar/src/taffybar.hs +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | |||
3 | module Main where | ||
4 | |||
5 | import System.Taffybar (startTaffybar) | ||
6 | import System.Taffybar.Context (TaffybarConfig(..)) | ||
7 | import System.Taffybar.Hooks | ||
8 | import System.Taffybar.SimpleConfig hiding (SimpleTaffyConfig(cssPaths)) | ||
9 | import System.Taffybar.Widget | ||
10 | import qualified System.Taffybar.Widget.Clock as MyClock | ||
11 | import System.Taffybar.Widget.TooltipBattery | ||
12 | |||
13 | import Data.Time.Format | ||
14 | import Data.Time.LocalTime | ||
15 | import Data.Time.Calendar.WeekDate | ||
16 | |||
17 | import qualified Data.Text as T | ||
18 | |||
19 | import Control.Exception (SomeException, try) | ||
20 | import Control.Monad.Trans.Reader (mapReaderT) | ||
21 | |||
22 | import Paths_gkleen_sif_taffybar | ||
23 | |||
24 | import System.Log.Logger | ||
25 | |||
26 | |||
27 | main :: IO () | ||
28 | main = do | ||
29 | logger <- getLogger "System.Taffybar" | ||
30 | saveGlobalLogger $ setLevel INFO logger | ||
31 | |||
32 | myCssPath <- getDataFileName "taffybar.css" | ||
33 | startTaffybar taffybarConfig{ cssPaths = pure myCssPath } | ||
34 | |||
35 | |||
36 | taffybarConfig :: TaffybarConfig | ||
37 | taffybarConfig = | ||
38 | let myWorkspacesConfig = | ||
39 | defaultWorkspacesConfig | ||
40 | { maxIcons = Just 0 | ||
41 | , widgetGap = 7 | ||
42 | , showWorkspaceFn = \case | ||
43 | -- Workspace{ workspaceState = Empty } -> False | ||
44 | Workspace{ workspaceName } | workspaceName == "NSP" -> False | ||
45 | _other -> True | ||
46 | , getWindowIconPixbuf = \i d -> either (\(_ :: SomeException) -> Nothing) id <$> mapReaderT try (defaultGetWindowIconPixbuf i d) | ||
47 | , urgentWorkspaceState = True | ||
48 | } | ||
49 | workspaces = workspacesNew myWorkspacesConfig | ||
50 | clock = MyClock.textClockNewWith MyClock.defaultClockConfig | ||
51 | { MyClock.clockUpdateStrategy = MyClock.RoundedTargetInterval 1 0.0 | ||
52 | , MyClock.clockFormat = \tl zt@ZonedTime{ zonedTimeToLocalTime = LocalTime{ localDay } } | ||
53 | -> let date = formatTime tl "%Y-%m-%d" localDay | ||
54 | weekdate = "W" <> show2 woy <> "-" <> show dow | ||
55 | where (_, woy, dow) = toWeekDate localDay | ||
56 | show2 :: Int -> String | ||
57 | show2 x = replicate (2 - length s) '0' ++ s | ||
58 | where s = show x | ||
59 | time = formatTime tl "%H:%M:%S%Ez" zt | ||
60 | in T.intercalate " " $ map T.pack [weekdate, date, time] | ||
61 | } | ||
62 | layout = layoutNew defaultLayoutConfig | ||
63 | windowsW = windowsNew defaultWindowsConfig | ||
64 | { getMenuLabel = truncatedGetMenuLabel 80 | ||
65 | , getActiveLabel = truncatedGetActiveLabel 80 | ||
66 | } | ||
67 | worktime = commandRunnerNew 60 "worktime" [] "worktime" | ||
68 | worktimeToday = commandRunnerNew 60 "worktime" ["today"] "worktime today" | ||
69 | -- See https://github.com/taffybar/gtk-sni-tray#statusnotifierwatcher | ||
70 | -- for a better way to set up the sni tray | ||
71 | -- tray = sniTrayThatStartsWatcherEvenThoughThisIsABadWayToDoIt | ||
72 | tray = sniTrayNew | ||
73 | myConfig = defaultSimpleTaffyConfig | ||
74 | { startWidgets = | ||
75 | workspaces : map (>>= buildContentsBox) [ layout, windowsW ] | ||
76 | , endWidgets = map (>>= buildContentsBox) $ reverse | ||
77 | -- , mpris2New | ||
78 | [ worktime, worktimeToday | ||
79 | , clock | ||
80 | , tray | ||
81 | , batteryIconTooltipNew "$status$ $percentage$%$if(time)$$if(rate)$ ($rate$W $time$)$else$ ($time$)$endif$$elseif(rate)$ ($rate$W)$endif$" | ||
82 | ] | ||
83 | , barPosition = Top | ||
84 | , barPadding = 2 | ||
85 | , barHeight = ExactSize 28 | ||
86 | , widgetSpacing = 10 | ||
87 | } | ||
88 | in withBatteryRefresh $ withLogServer $ | ||
89 | withToggleServer $ toTaffyConfig myConfig | ||