Update README.md info and instructions
This commit is contained in:
67
README.md
67
README.md
@ -1,9 +1,13 @@
|
|||||||
# xmonad-log
|
# xmonad-log
|
||||||
|
|
||||||
xmonad-log is a DBus monitoring solution that can easily be used to display
|
xmonad-log-multiscreen is a DBus monitoring solution that can easily be used to display
|
||||||
xmonad in a statusbar like [polybar](https://github.com/jaagr/polybar),
|
xmonad in a statusbar like [polybar](https://github.com/jaagr/polybar),
|
||||||
[lemonbar](https://github.com/LemonBoy/bar) and similar.
|
[lemonbar](https://github.com/LemonBoy/bar) and similar.
|
||||||
|
|
||||||
|
This fork allows you to add a custom ID (by passing it as the first argument) that allows you to use marshallPP and screen independent pretty printing. This allows you to have a bar on each screen and will show the correct focus on each screen.
|
||||||
|
|
||||||
|
There is an example configuration provided below which will show you how to use the screen index as the log id. The log id supports any string that supports characters of a valid path.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
xmonad-log is written in Go with one dependency:
|
xmonad-log is written in Go with one dependency:
|
||||||
@ -28,6 +32,15 @@ To configure xmonad to send log events over DBus the haskell
|
|||||||
installed the following can be added to your `.xmonad/xmonad.hs` configuration
|
installed the following can be added to your `.xmonad/xmonad.hs` configuration
|
||||||
to add DBus support.
|
to add DBus support.
|
||||||
|
|
||||||
|
|
||||||
|
View [this
|
||||||
|
xmonad-config](https://github.com/xintron/configs/blob/22a33b41587c180172392f80318883921c543053/.xmonad/lib/Config.hs#L199)
|
||||||
|
for a fully working polybar example using statusbar coloring.
|
||||||
|
|
||||||
|
Both xmonad examples below do the same exact thing however the second one might make it easier to map the xmonad logging output to something that is more easy to identify, ex: display id.
|
||||||
|
Note: According to dbus specification, paths can only contain numbers, letters, underscores, and the / character, so you cannot enter the log id as "DP-0" but rather "DP_0". If you have a script that spawns your bar based on the display, you must have the script replace the '-' with '_' from your xrandr query.
|
||||||
|
|
||||||
|
Screen index id as xmonad-log log id config
|
||||||
```haskell
|
```haskell
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Hooks.DynamicLog
|
import XMonad.Hooks.DynamicLog
|
||||||
@ -43,26 +56,60 @@ main = do
|
|||||||
D.requestName dbus (D.busName_ "org.xmonad.Log")
|
D.requestName dbus (D.busName_ "org.xmonad.Log")
|
||||||
[D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
|
[D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
|
||||||
|
|
||||||
xmonad $ def { logHook = dynamicLogWithPP (myLogHook dbus) }
|
-- Example of setting up logging for the first two screens
|
||||||
|
xmonad $ def { logHook = dynamicLogWithPP (myLogHook dbus 0) <+> dynamicLogWithPP (myLogHook dbus 1) }
|
||||||
|
|
||||||
-- Override the PP values as you would otherwise, adding colors etc depending
|
-- Override the PP values as you would otherwise, adding colors etc depending
|
||||||
-- on the statusbar used
|
-- on the statusbar used
|
||||||
myLogHook :: D.Client -> PP
|
myLogHook :: D.Client -> Int -> PP
|
||||||
myLogHook dbus = def { ppOutput = dbusOutput dbus }
|
myLogHook dbus id = marshallPP (S id) $ def { ppOutput = dbusOutput dbus id }
|
||||||
|
|
||||||
-- Emit a DBus signal on log updates
|
-- Emit a DBus signal on log updates
|
||||||
dbusOutput :: D.Client -> String -> IO ()
|
dbusOutput :: D.Client -> Int -> String -> IO ()
|
||||||
dbusOutput dbus str = do
|
dbusOutput dbus id str = do
|
||||||
let signal = (D.signal objectPath interfaceName memberName) {
|
let signal = (D.signal objectPath interfaceName memberName) {
|
||||||
D.signalBody = [D.toVariant $ UTF8.decodeString str]
|
D.signalBody = [D.toVariant $ UTF8.decodeString str]
|
||||||
}
|
}
|
||||||
D.emit dbus signal
|
D.emit dbus signal
|
||||||
where
|
where
|
||||||
objectPath = D.objectPath_ "/org/xmonad/Log"
|
objectPath = D.objectPath_ ("/org/xmonad/Log_" ++ show id)
|
||||||
interfaceName = D.interfaceName_ "org.xmonad.Log"
|
interfaceName = D.interfaceName_ "org.xmonad.Log"
|
||||||
memberName = D.memberName_ "Update"
|
memberName = D.memberName_ "Update"
|
||||||
```
|
```
|
||||||
|
|
||||||
View [this
|
Custom log id as xmonad-log log id config
|
||||||
xmonad-config](https://github.com/xintron/configs/blob/22a33b41587c180172392f80318883921c543053/.xmonad/lib/Config.hs#L199)
|
```haskell
|
||||||
for a fully working polybar example using statusbar coloring.
|
import XMonad
|
||||||
|
import XMonad.Hooks.DynamicLog
|
||||||
|
|
||||||
|
import qualified DBus as D
|
||||||
|
import qualified DBus.Client as D
|
||||||
|
import qualified Codec.Binary.UTF8.String as UTF8
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
dbus <- D.connectSession
|
||||||
|
-- Request access to the DBus name
|
||||||
|
D.requestName dbus (D.busName_ "org.xmonad.Log")
|
||||||
|
[D.nameAllowReplacement, D.nameReplaceExisting, D.nameDoNotQueue]
|
||||||
|
|
||||||
|
-- Example of setting up logging for the first two screens
|
||||||
|
xmonad $ def { logHook = dynamicLogWithPP (myLogHook dbus 0 "DP-2") <+> dynamicLogWithPP (myLogHook dbus 1 "DP-0") }
|
||||||
|
|
||||||
|
-- Override the PP values as you would otherwise, adding colors etc depending
|
||||||
|
-- on the statusbar used
|
||||||
|
myLogHook :: D.Client -> Int -> String -> PP
|
||||||
|
myLogHook dbus id log_id = marshallPP (S id) $ def { ppOutput = dbusOutput dbus log_id }
|
||||||
|
|
||||||
|
-- Emit a DBus signal on log updates
|
||||||
|
dbusOutput :: D.Client -> String -> String -> IO ()
|
||||||
|
dbusOutput dbus log_id str = do
|
||||||
|
let signal = (D.signal objectPath interfaceName memberName) {
|
||||||
|
D.signalBody = [D.toVariant $ UTF8.decodeString str]
|
||||||
|
}
|
||||||
|
D.emit dbus signal
|
||||||
|
where
|
||||||
|
objectPath = D.objectPath_ ("/org/xmonad/Log_" ++ log_id)
|
||||||
|
interfaceName = D.interfaceName_ "org.xmonad.Log"
|
||||||
|
memberName = D.memberName_ "Update"
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user