Reputation: 69
I am new to Haskell and trying to get the xmobar.hs
to work (as I import colours into the bar via pywal's colors.hs
file as directed in the file itself). I have managed to get this working, as well as a number of modules. Unfortunately, I have run into a few issues, described below. I accept these are likely entirely due to my unfamiliarity with the language.
In terms of installation, Xmonad was installed via Stack, on Arch Linux x86_64.
Please find all relevant files at the bottom of this question.
The following occurs when restarting xmonad, either via the terminal, or through the shortcut mod + q
Run Com
) and inbuilt plugins do not work without a $
between Run and the plugin name (except for Run XMonadLog
)$
throws an error causing xmobar to not runxmobar -x 0 ~/.config/xmonad/xmobar.hs
, I am given the following; The function ‘Run’ is applied to four value arguments, but its type ‘(Interface -> Args -> Rate -> Monitors) -> Runnable’ has only one
, upon trying to carry out the command Run Network
, for instance$
is included in all relevant commands, Run Com
's behaviour is seemingly erratic; sometimes xmobar displays the output, sometimes it stays on Updating...
date
being polled and manipulated each second, I thought this may be the issue. However, testing MarqueePipeReader
which is simply reading text sent to a file in /tmp/
, also renders the same issueI did note some (older) answers here referring to XMonad.Hooks.DynamicLog
but as seen in the documentation, this is now apparently a compatibility wrapper for more modern modules, both of which are used in the file below.
This takes heavily from the official Haskell tutorial, changing very little.
import XMonad
import XMonad.Util.EZConfig
import XMonad.Hooks.EwmhDesktops
import XMonad.Actions.RepeatAction
import XMonad.Util.Loggers
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
import Colors
import XMonad.Layout.ThreeColumns
import qualified XMonad.Layout.Magnifier as Mag
main :: IO ()
main = xmonad
. ewmhFullscreen
. ewmh
. withEasySB (statusBarProp "xmobar /home/user/.config/xmonad/xmobar.hs" (pure myXmobarPP)) defToggleStrutsKey
$ myConfig
myConfig = def
{
modMask = mod4Mask -- rebind mod to super
}
myLayout = tiled ||| Mirror tiled ||| Full ||| threeCol
where
threeCol = Mag.magnifiercz' 1.4 $ ThreeColMid nmaster delta ratio
tiled = smartBorders $ Tall nmaster delta ratio
nmaster = 1 -- default number of windows in master pane
ratio = 1/2 -- default proportion of screen occupied by master pane
delta = 4/100 -- percent of screen to increment when resizing panes
myXmobarPP :: PP
myXmobarPP = def
{
ppSep = color2 " • "
, ppTitleSanitize = xmobarStrip
, ppCurrent = wrap (color3 "[ ") (color3 " ]")
, ppVisible = wrap " " " "
, ppHidden = color6 . wrap " " " "
, ppHiddenNoWindows = color7 . wrap " " " "
, ppUrgent = color6 . wrap (color5 "!") (color5 "!")
, ppOrder = \[ws, l, _, wins] -> [ws, wins]
, ppExtras = [logTitles formatFocused formatUnfocused]
}
where
formatFocused = wrap (color3 "[") (color3 "]") . color2 . ppWindow
formatUnfocused = wrap (color7 "[") (color7 "]") . color3 . ppWindow
-- windows' title should not exceed certain length
ppWindow :: String -> String
ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30
color1, color2, color3, color4, color5, color6, color7, color8 :: String -> String
color1 = xmobarColor Colors.color1 ""
color2 = xmobarColor Colors.color2 ""
color3 = xmobarColor Colors.color3 ""
color4 = xmobarColor Colors.color4 ""
color5 = xmobarColor Colors.color5 ""
color6 = xmobarColor Colors.color6 ""
color7 = xmobarColor Colors.color7 ""
color8 = xmobarColor Colors.color8 ""
This is a modification from the official repo. Again, very little is changed here.
import Xmobar
import Colors
config :: Config
config = defaultConfig { overrideRedirect = True
, font = "M PLUS 1 Code Regular 10"
, additionalFonts = [ "Font Awesome-6 Regular 12"
, "Noto Emoji Regular 12"
]
, bgColor = Colors.color2
, fgColor = "#f8f8f2"
, alpha = 100
, position = TopHM 36 40 40 8 0
, lowerOnStart = True
, pickBroadest = False
, persistent = False
, hideOnStart = False
, iconRoot = "."
, allDesktops = True
, textOutputFormat = Ansi
, commands = [ Run Network "wlan0" [
"-H","32",
"--low",Colors.color5,
"--normal",Colors.color6,
"--high",Colors.color7,
"-t","<fn=1>\xf1eb</fn> <rx> KB/s | <tx> KB/s"
]
10
, Run $ Com "/bin/bash" ["-c", "/home/user/clock/sh/clock.sh"] "clock" 1
, Run XMonadLog
]
, sepChar = "%"
, alignSep = "}{"
, template = " %wlan0%}%XMonadLog%{%clock% "
}
main :: IO ()
main = configFromArgs config >>= xmobar
Any help on this would be much appreciated, thank you very much.
Upvotes: 0
Views: 212