You are not logged in.

#1 2021-06-20 21:40:25

Gian-Laager
Member
Registered: 2021-06-11
Posts: 22

Xmobar doesn't start when launching Xmonad with a display manager.

I've desided to install a display manager, sofar I've tried lxdm and lightdm. As a window manager I'm using Xmonad with Xmobar this is my Xmonad config (~/.xmonad/xmonad.hs):

-- Imports.
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Layout.Spacing
import XMonad.Hooks.ManageDocks (ToggleStruts)
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Grid
import XMonad.Layout.NoBorders

-- The main function.
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig

-- Command to launch the bar.
myBar = "xmobar"

-- Custom PP, configure it as you like. It determines what is being written to the bar.
myPP = xmobarPP { ppCurrent = xmobarColor "#429942" "" . wrap "<" ">" }

-- Key binding to toggle the gap for the bar.
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)

defaultSpacing = 17

-- Main configuration, override the defaults to your liking.
myLayout = (spacing defaultSpacing $ Tall 1 (3/100) (1/2))
                                         ||| (spacing defaultSpacing $ ThreeCol 1 (3/100) (1/2))
                                         ||| (spacing defaultSpacing $ Full)
                                         ||| (noBorders $ Full)
myConfig = def {
        modMask = mod4Mask,
        terminal="alacritty",
        layoutHook = myLayout,
        focusedBorderColor = "#D79B55",
        normalBorderColor = "#BBC2CF",
        borderWidth = 3,
        startupHook = spawn "~/.onXmonadStart"
}

and this the ~/.onXmonadStart file wich I created because I had problems that .xinitrc wasn't executed correctly by the display managers:

setxkbmap -model asus_laptop -layout ch
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --output DP-0 --primary --mode 3440x1440 --scale 1x1 --pos 0x0
xrandr --output eDP-1-0 --mode 1920x1080
xrandr --output eDP-1-0 --pos 440x1440
xmodmap ~/.Xomdmap
xinput set-prop "ELAN1201:00 04F3:3098 Touchpad" "libinput Tapping Enabled" 1
xinput set-prop "ELAN1201:00 04F3:3098 Touchpad" "libinput Tapping Drag Lock Enabled" 1
brightnessctl --device='asus::kbd_backlight' set 3
xrbd -merge ~/.Xresources
xbindkeys --poll-rc
nitrogen --restore &
picom &
xmobar ~/.xmobarrc &

my .xinitrc is the default config file except that I'm starting Xmonad instead of all the other things.

When I launch Xmonad with startx from the tty Xmobar starts with out any errors, but If the display manger starts it, Xmobar doesn't appear and when I try to start it manualy with "xmobar ~/.xmobarrc" it gives me this error message:

xmobar: ~/.xmobarrc: hGetContents: invalid argument (invalid byte sequence)

Any ideas how I could fix that?

Offline

#2 2021-06-21 08:44:15

Tétrapyle
Member
Registered: 2014-01-03
Posts: 61

Re: Xmobar doesn't start when launching Xmonad with a display manager.

Hi.
I'm not sure this is relevant but please note that the documentation is not up-to-date with the source code.
If I read correctly this: https://github.com/jaor/xmobar/blob/mas … /Config.hs , an xmobar XDG directory might have been created by the program.
I ran with such an issue some time ago. I suggest you copy your config file under something like ~/XDG_CONFIG_HOME/xmobar/xmobar.hs and then try to launch xmobar without specifying the config file.

Offline

#3 2021-07-02 03:40:16

nicolassilvar
Member
From: Bogota
Registered: 2016-06-15
Posts: 24

Re: Xmobar doesn't start when launching Xmonad with a display manager.

I'm having the same issue

I have the file under XDG_CONFIG_HOME as per XDG_Base_Directory

This is my xmbobarrc

Config { font    = "xft:Ubuntu:weight=bold:pixelsize=11:antialias=true:hinting=true"
       , additionalFonts = [ "xft:Mononoki Nerd Font:pixelsize=11:antialias=true:hinting=true"
                           , "xft:Font Awesome 5 Free Solid:pixelsize=12"
                           , "xft:Font Awesome 5 Brands:pixelsize=12"
                           ]
       , bgColor = "#282c34"
       , fgColor = "#ff6c6b"
       , position = Static { xpos = 0 , ypos = 0, width = 1920, height = 24 }
       , lowerOnStart = True
       , hideOnStart = False
       , allDesktops = True
       , persistent = True
       , iconRoot = "/home/dt/.xmonad/xpm/"  -- default: "."
       , commands = [
                    -- Time and date
                      Run Date "<fn=2>\xf017</fn>  %b %d %Y - (%H:%M) " "date" 50
                      -- Network up and down
                    , Run Network "enp6s0" ["-t", "<fn=2>\xf0ab</fn>  <rx>kb  <fn=2>\xf0aa</fn>  <tx>kb"] 20
                      -- Cpu usage in percent
                    , Run Cpu ["-t", "<fn=2>\xf108</fn>  cpu: (<total>%)","-H","50","--high","red"] 20
                      -- Ram used number and percent
                    , Run Memory ["-t", "<fn=2>\xf233</fn>  mem: <used>M (<usedratio>%)"] 20
                      -- Disk space free
                    , Run DiskU [("/", "<fn=2>\xf0c7</fn>  hdd: <free> free")] [] 60
                      -- Runs custom script to check for pacman updates.
                      -- This script is in my dotfiles repo in .local/bin.
                    , Run Com "/home/dt/.local/bin/pacupdate" [] "pacupdate" 36000
                      -- Runs a standard shell command 'uname -r' to get kernel version
                    , Run Com "uname" ["-r"] "" 3600
                    , Run UnsafeStdinReader
                    ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = " <icon=haskell_20.xpm/>   <fc=#666666>|</fc> %UnsafeStdinReader% }{  <fc=#666666>|</fc>  <fc=#b3afc2><fn=3></fn>  <action=`alacritty -e htop`>%uname%</action> </fc> <fc=#666666>|</fc>  <fc=#ecbe7b> <action=`alacritty -e htop`>%cpu%</action> </fc> <fc=#666666>|</fc>  <fc=#ff6c6b> <action=`alacritty -e htop`>%memory%</action> </fc> <fc=#666666>|</fc>  <fc=#51afef> <action=`alacritty -e htop`>%disku%</action> </fc> <fc=#666666>|</fc>  <fc=#98be65> <action=`alacritty -e sudo iftop`>%enp6s0%</action> </fc> <fc=#666666>|</fc>   <fc=#c678dd><fn=2></fn>  <action=`alacritty -e sudo pacman -Syu`>%pacupdate%</action> </fc> <fc=#666666>|</fc>  <fc=#46d9ff> <action=`emacsclient -c -a 'emacs' --eval '(doom/window-maximize-buffer(dt/year-calendar))'`>%date%</action>  </fc>"
       }

Last edited by nicolassilvar (2021-07-02 03:42:08)

Offline

#4 2021-07-02 15:30:05

Tétrapyle
Member
Registered: 2014-01-03
Posts: 61

Re: Xmobar doesn't start when launching Xmonad with a display manager.

According to the source file, if I understand it correctly, once the config directory has been determined and, maybe, created, it looks first for xmobar.hs, then for .xmobarrc, and after that for xmobarrc .

env <- lookupEnv "XMOBAR_CONFIG_DIR"
xdg <- getXdgDirectory XdgConfig "xmobar"
app <- getAppUserDataDirectory "xmobar"
hom <- getHomeDirectory
let candidates = case env of
                   Nothing -> [app, xdg, hom]
                   Just p -> [p, app, xdg, hom]

According to this, if you have ~/.xmobar/ and ~/.config/xmobar/ directories, the former would be used for the config file.
This ~/.xmobar could have been created without your knowledge as a place to write the `configuration binary generated by GHC'. If I understand correctly.
And then, xmobar would look for a config source file in this directory and wouldn't find it. That could be the reason for this mess.

Offline

#5 2021-07-02 23:44:45

nicolassilvar
Member
From: Bogota
Registered: 2016-06-15
Posts: 24

Re: Xmobar doesn't start when launching Xmonad with a display manager.

Thanks for pointing it out, I dont have a ./.xmobar file, I only have a file under ~/.config/xmobar/ directory

The xmonad.hs file, call is as:

main = do
    xmproc0 <- spawnPipe "xmobar -x 0 $HOME/.config/xmobar/xmobarrc"

Nothing show up in my xmonad desktop, I'm only able to capture the error by running the xmobar command in the command line.

Offline

Board footer

Powered by FluxBB