status-notifier-item 0.3.1.0 → 0.3.2.0
raw patch · 6 files changed
+70/−16 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ StatusNotifier.Util: splitServiceName :: String -> (String, Maybe String)
Files
- ChangeLog.md +5/−1
- README.md +25/−1
- src/StatusNotifier/Host/Service.hs +13/−7
- src/StatusNotifier/Util.hs +7/−0
- src/StatusNotifier/Watcher/Service.hs +19/−6
- status-notifier-item.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@ # Changelog for status-notifier-item -## Unreleased changes+## 0.3.2.0 - 2026-02-05+- Report full `bus/path` identifiers for non-default SNI object paths so hosts+ can resolve Ayatana items reliably.+- Accept `bus/path` identifiers in watcher/host lookups for compatibility with+ pathful registrations.
README.md view
@@ -1,2 +1,26 @@-# status-notifier-item [](https://travis-ci.org/taffybar/status-notifier-item)+# status-notifier-item++[](https://hackage.haskell.org/package/status-notifier-item) [](http://stackage.org/lts/package/status-notifier-item) [](http://stackage.org/nightly/package/status-notifier-item) +The status-notifier-item package provides a haskell implementation of the [status-notifier-item](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/)/[app-indicator](https://github.com/ubuntu/gnome-shell-extension-appindicator/blob/master/interfaces-xml/StatusNotifierItem.xml) protocol.++StatusNotifierHost+------------------++The host server implementation provided is partial in the sense that it is headless (provides no graphical interface), and it is supposed to be used together with UI code that handles actually displaying a tray. The [gtk-sni-tray](https://github.com/taffybar/gtk-sni-tray) provides a gtk tray widget that is implemented using the status-notifier-item library. [taffybar](https://github.com/taffybar/taffybar) Uses gtk-sni-tray to provide a tray widget that can be used with the many other widgets it offers.++StatusNotifierWatcher+---------------------++This package provides a standalone status-notifier-watch binary that can be run on its own to handle the registration of status-notifier-items. By default, it is necessary to run this binary before starting either [taffybar](https://github.com/taffybar/taffybar) or [gtk-sni-tray](https://github.com/taffybar/gtk-sni-tray), becuase the trays provided in those binaries do not handle this responsibility. If this is not done, those binaries will fail at startup with this message:++```+MethodError {methodErrorName = ErrorName "org.freedesktop.DBus.Error.ServiceUnknown", methodErrorSerial = Serial 7, methodErrorSender = Just (BusName "org.freedesktop.DBus"), methodErrorDestination = Just (BusName ":1.549"), methodErrorBody = [Variant "The name org.kde.StatusNotifierWatcher was not provided by any .service files"]}+```++A client library is also provided for the StatusNotifierWatcher protocol++StatusNotifierItem+------------------++This package provides a client library for calling into status notifier items. It also provides a sample implementation of the server side of the StatusNotifierItem protocol as well as a `status-notifier-item-static` binary that uses this implementation. This binary can be used to test host and watcher implementations, but it mostly just serves as an example of how to implement the protocol using this library, as it does not really do anything useful.
src/StatusNotifier/Host/Service.hs view
@@ -158,11 +158,17 @@ getMaybe fn a b c = right Just <$> fn a b c + parseServiceName name =+ let (bus, maybePath) = splitServiceName name+ in (busName_ bus, objectPath_ <$> maybePath)+ buildItemInfo name = runExceptT $ do- pathString <- ExceptT $ W.getObjectPathForItemName client name- let busName = fromString name- path = objectPath_ pathString- doGetDef def fn =+ let (busName, maybePath) = parseServiceName name+ path <- case maybePath of+ Just parsedPath -> return parsedPath+ Nothing -> objectPath_ <$> ExceptT+ (W.getObjectPathForItemName client (coerce busName))+ let doGetDef def fn = ExceptT $ exemptAll def <$> fn client busName path doGet fn = ExceptT $ fn client busName path pixmaps <- doGetDef [] $ getPixmaps I.getIconPixmap@@ -176,9 +182,9 @@ idString <- doGetDef Nothing $ getMaybe I.getId status <- doGetDef Nothing $ getMaybe I.getStatus category <- doGetDef Nothing $ getMaybe I.getCategory- itemIsMenu <- doGetDef False I.getItemIsMenu+ itemIsMenu <- doGetDef True I.getItemIsMenu return ItemInfo- { itemServiceName = busName_ name+ { itemServiceName = busName , itemId = idString , itemStatus = status , itemCategory = category@@ -227,7 +233,7 @@ modifyMVar itemInfoMapVar doRemove >>= maybe logNonExistentRemoval (doUpdate ItemRemoved) where- busName = busName_ serviceName+ busName = fst (parseServiceName serviceName) doRemove currentMap = return (Map.delete busName currentMap, Map.lookup busName currentMap) logNonExistentRemoval =
src/StatusNotifier/Util.hs view
@@ -21,6 +21,13 @@ import System.ByteOrder (fromBigEndian) import System.Log.Logger +splitServiceName :: String -> (String, Maybe String)+splitServiceName name =+ case break (=='/') name of+ (bus, "") -> (bus, Nothing)+ (bus, path) | not (null bus) -> (bus, Just path)+ _ -> (name, Nothing)+ getIntrospectionObjectFromFile :: FilePath -> T.ObjectPath -> Q I.Object getIntrospectionObjectFromFile filepath nodePath = runIO $ head . maybeToList . I.parseXML nodePath <$> TIO.readFile filepath
src/StatusNotifier/Watcher/Service.hs view
@@ -50,6 +50,15 @@ let itemIsRegistered item items = isJust $ find (== item) items+ renderServiceName ItemEntry { serviceName = busName+ , servicePath = path+ } =+ let bus = coerce busName+ objPath = coerce path+ defaultPath = coerce Item.defaultPath+ in if objPath == defaultPath+ then bus+ else bus ++ objPath registerStatusNotifierItem MethodCall { methodCallSender = sender }@@ -75,7 +84,7 @@ return currentItems else do- emitStatusNotifierItemRegistered client $ coerce busName+ emitStatusNotifierItemRegistered client $ renderServiceName item return $ item : currentItems registerStatusNotifierHost name =@@ -93,7 +102,7 @@ registeredStatusNotifierItems :: IO [String] registeredStatusNotifierItems =- map (coerce . serviceName) <$> readMVar notifierItems+ map renderServiceName <$> readMVar notifierItems registeredSNIEntries :: IO [(String, String)] registeredSNIEntries =@@ -102,9 +111,12 @@ objectPathForItem :: String -> IO (Either Reply String) objectPathForItem name =- maybeToEither notFoundError . fmap (coerce . servicePath) .- find ((== busName_ name) . serviceName) <$>- readMVar notifierItems+ case splitServiceName name of+ (_, Just path) -> return $ Right path+ (bus, Nothing) ->+ maybeToEither notFoundError . fmap (coerce . servicePath) .+ find ((== busName_ bus) . serviceName) <$>+ readMVar notifierItems where notFoundError = makeErrorReply errorInvalidParameters $ printf "Service %s is not registered." name@@ -122,7 +134,8 @@ removedItems <- filterDeadService name notifierItems unless (null removedItems) $ do log $ printf "Unregistering item %s because it disappeared." name- emitStatusNotifierItemUnregistered client name+ forM_ removedItems $ \item ->+ emitStatusNotifierItemUnregistered client $ renderServiceName item removedHosts <- filterDeadService name notifierHosts unless (null removedHosts) $ log $ printf "Unregistering host %s because it disappeared." name
status-notifier-item.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: status-notifier-item-version: 0.3.1.0+version: 0.3.2.0 synopsis: A wrapper over the StatusNotifierItem/libappindicator dbus specification description: Please see the README on Github at <https://github.com/IvanMalison/status-notifier-item#readme> category: Desktop