diff options
-rw-r--r-- | changelog.md | 8 | ||||
-rw-r--r-- | doc/plugins.org | 18 | ||||
-rw-r--r-- | src/Xmobar.hs | 2 | ||||
-rw-r--r-- | src/Xmobar/Plugins/ArchUpdates.hs | 41 | ||||
-rw-r--r-- | src/Xmobar/Run/Types.hs | 2 | ||||
-rw-r--r-- | xmobar.cabal | 1 |
6 files changed, 69 insertions, 3 deletions
diff --git a/changelog.md b/changelog.md index 6306c03..20308fd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ ## Version 0.49 (unreleased) +- New plugin: `ArchUpdates` (thanks, Enrico Maria) + + +## Version 0.48.1 (May, 2024) + +- Removing for now mouse support for `Kbd`, which can be recovered by + interested users using regular actions (see issue #703 for further details). + ## Version 0.48 (April, 2024) - The `Kbd` monitor is now clickable (thanks, Enrico Maria) diff --git a/doc/plugins.org b/doc/plugins.org index f27d7ff..3433df3 100644 --- a/doc/plugins.org +++ b/doc/plugins.org @@ -1321,7 +1321,7 @@ #+begin_src haskell Run UVMeter "Brisbane" ["-H", "3", "-L", "3", "--low", "green", "--high", "red"] 900 #+end_src -** Other monitors +** Other monitors and plugins *** =CatInt n filename= - Reads and displays an integer from the file whose path is =filename= @@ -1351,6 +1351,20 @@ the display of those numeric fields. - Default template: =Up: <days>d <hours>h <minutes>m= +*** =ArchUpdates (Zero, One, Many) Rate= + + - Aliases to =arch= + - =Zero=: a =String= to use when the system is up to date. + - =One=: a =String= to use when only one update is available. + - =Many=: a =String= to use when several updates are available; it must contain + a =?= character as a placeholder for the number of updates. + - Example: + #+begin_src haskell + ArchUpdates ("<fc=green>up to date</fc>", + "<fc=yellow>1 update</fc>, + "<fc=red>? updates</fc>") + 600 + #+end_src * Interfacing with window managers :PROPERTIES: :CUSTOM_ID: interfacing-with-window-managers @@ -1575,8 +1589,6 @@ xmonad configuration (=xmonad.hs=), e.g. by using a custom =~/.xmonad/build= script. - - * Executing external commands In order to execute an external command you can either write the diff --git a/src/Xmobar.hs b/src/Xmobar.hs index ced40a5..374825b 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -26,6 +26,7 @@ module Xmobar (xmobar , SignalType (..) , module Xmobar.Config.Types , module Xmobar.Config.Parse + , module Xmobar.Plugins.ArchUpdates , module Xmobar.Plugins.BufferedPipeReader , module Xmobar.Plugins.CommandReader , module Xmobar.Plugins.Date @@ -53,6 +54,7 @@ import Xmobar.Run.Runnable import Xmobar.Run.Exec import Xmobar.Config.Types import Xmobar.Config.Parse +import Xmobar.Plugins.ArchUpdates import Xmobar.Plugins.Command import Xmobar.Plugins.BufferedPipeReader import Xmobar.Plugins.CommandReader diff --git a/src/Xmobar/Plugins/ArchUpdates.hs b/src/Xmobar/Plugins/ArchUpdates.hs new file mode 100644 index 0000000..f803d0f --- /dev/null +++ b/src/Xmobar/Plugins/ArchUpdates.hs @@ -0,0 +1,41 @@ +{-# LANGUAGE CPP #-} + +----------------------------------------------------------------------------- +-- | +-- Module : Plugins.Monitors.ArchUpdates +-- Copyright : (c) 2024 Enrico Maria De Angelis +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : Enrico Maria De Angelis <enricomaria.dean6elis@gmail.com> +-- Stability : unstable +-- Portability : unportable +-- +-- An ArchLinux updates availablility plugin for Xmobar +-- +----------------------------------------------------------------------------- + +module Xmobar.Plugins.ArchUpdates (ArchUpdates(..)) where + +import System.Exit (ExitCode(..)) +import System.Process (readProcessWithExitCode) +import Xmobar.Run.Exec +import Xmobar.Plugins.Command (Rate) + +data ArchUpdates = ArchUpdates (String, String, String) Rate + deriving (Read, Show) + +instance Exec ArchUpdates where + alias (ArchUpdates _ _) = "arch" + rate (ArchUpdates _ r) = r + run (ArchUpdates (z, o, m) _) = do + (exit, stdout, _) <- readProcessWithExitCode "checkupdates" [] "" + return $ case exit of + ExitFailure 2 -> z--ero updates + ExitFailure 1 -> "pacman: Unknown cause of failure." + ExitSuccess -> case length $ lines stdout of + 0 -> impossible + 1 -> o + n -> m >>= \c -> if c == '?' then show n else pure c + _ -> impossible + where + impossible = error "This is impossible based on pacman manpage" diff --git a/src/Xmobar/Run/Types.hs b/src/Xmobar/Run/Types.hs index 69406bb..bb573c8 100644 --- a/src/Xmobar/Run/Types.hs +++ b/src/Xmobar/Run/Types.hs @@ -19,6 +19,7 @@ module Xmobar.Run.Types(runnableTypes) where import {-# SOURCE #-} Xmobar.Run.Runnable() +import Xmobar.Plugins.ArchUpdates import Xmobar.Plugins.Command import Xmobar.Plugins.Monitors import Xmobar.Plugins.Date @@ -59,6 +60,7 @@ infixr :*: runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: BufferedPipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*: Locks :*: NotmuchMail :*: + ArchUpdates :*: #ifdef INOTIFY Mail :*: MBox :*: #endif diff --git a/xmobar.cabal b/xmobar.cabal index e6de840..8a31619 100644 --- a/xmobar.cabal +++ b/xmobar.cabal @@ -149,6 +149,7 @@ library Xmobar.X11.Text, Xmobar.X11.Types, Xmobar.X11.Window, + Xmobar.Plugins.ArchUpdates, Xmobar.Plugins.Command, Xmobar.Plugins.BufferedPipeReader, Xmobar.Plugins.CommandReader, |