Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Autostart in XMonad

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
kamwitsta
Posts: 8
Joined: 2015-01-05 21:16

[Solved] Autostart in XMonad

#1 Post by kamwitsta »

I have Debian 12 (stable). I chose to install Gnome during the installation but later added XMonad. I have a problem with two things, both of which could be solved by autorunning a command on startup. One is dzen (status bar), and the other my custom keyboard layout (set via setxkbmap). I tried adding them to:
  • ~/.xsession, ~/.xsessionrc, ~/.xinitrc,
  • ~/.config/autostart, and /etc/xdg/autostart,
  • ~/.xmonad/xmonad.hs as startupHook,
but nothing seems to work.

The keyboard layout is set as the default one in Gnome and loads properly when I start Gnome instead of XMonad. However, dpkg-reconfigure keyboard-configuration does not see it even though I added it to /usr/share/X11/xkb/rules/base.lst, base.xml, evdev.lst, and evdev.xml.
I also tried creating /etc/X11/xorg.conf.d/10-keyboard.conf. This does load my layout in XMonad but for some reason it also disables the arrow keys. Also, when the layout is loaded via setxkbmap, and I type a dead key, it shows a preview of the diacritic that will be added while waiting for the second key to be pressed. When the layout is loaded via 10-keyboard.conf, it doesn't show this preview anymore. I quite like the preview, I'd like to have it – and the arrow keys too.
Last edited by kamwitsta on 2023-08-23 21:48, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Autostart in XMonad

#2 Post by Head_on_a_Stick »

How are you starting XMonad?

Adding commands to ~/.xsessionrc should work for all X sessions so please share exactly what was added, verbatim and in full. Thanks.

I can't remember if XMonad uses XDG autostart but if it did you would have to use a .desktop file to call a startup script.
deadbang

kamwitsta
Posts: 8
Joined: 2015-01-05 21:16

Re: Autostart in XMonad

#3 Post by kamwitsta »

Thanks. I start XMonad via gdm3 – with autologin, if that matters. I don't really care about gdm3, it's just what got installed together with Gnome, so I can change it if you think it would help.

Right now my .xsessionrc only has four uncommented lines in it:

Code: Select all

# this seems to work
amixer -q set Master off &

# those don't work
/home/kamil/conf/dzen.sh &
setxkbmap pl_lng -variant latin
The files in ~/.config/autostart and /etc/xdg/autostart were .desktop files.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Autostart in XMonad

#4 Post by Head_on_a_Stick »

So does /home/kamil/conf/dzen.sh work if you run it from a terminal?

Is there anything in XMonad's configuration that might be overriding `setxkbmap`? And does that command work as expected from a terminal?

GDM is useless bloat but it can't be causing the problem if the first command in ~/.xsessionrc works.
deadbang

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1423
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 47 times
Been thanked: 68 times

Re: Autostart in XMonad

#5 Post by None1975 »

kamwitsta wrote: 2023-08-21 14:58 I have Debian 12 (stable). I chose to install Gnome during the installation but later added XMonad. I have a problem with two things, both of which could be solved by autorunning a command on startup. One is dzen (status bar), and the other my custom keyboard layout (set via setxkbmap). I tried adding them to:
  • ~/.xsession, ~/.xsessionrc, ~/.xinitrc,
  • ~/.config/autostart, and /etc/xdg/autostart,
  • ~/.xmonad/xmonad.hs as startupHook,
but nothing seems to work.

The keyboard layout is set as the default one in Gnome and loads properly when I start Gnome instead of XMonad.
For keyboard layout, your should add line to the

Code: Select all

.xsessionrc

Code: Select all

setxkbmap -layout "us,lt,ru" -option "grp:alt_shift_toggle"
where us,lt,ru is your preferred keyboard layout and alt_shift is your keybinding for changing layout.

Here example of my .xsessionrc

Code: Select all

#!/bin/bash

nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"

nvidia-settings -a 'AllowFlipping=0'

picom --config /home/mindaugas/.config/picom/picom.conf &


hsetroot -tile Pictures/wall/egypt.jpg

setxkbmap -layout "us,lt,ru" -option "grp:alt_shift_toggle"

/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 &

xautolock -time 10 -locker "i3lock" &

#gkrellm &
Keep in mind, that .xsessionrc file must be executable. chmod +x .xsessionrc will do that.

About dzen2.

Your should consult the xmonad documentation. For dzen2, your should check this

But you can use more simple solution. It is

Code: Select all

xmobar
Just look at my configs You will find many examples that will be useful to you.
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

kamwitsta
Posts: 8
Joined: 2015-01-05 21:16

Re: Autostart in XMonad

#6 Post by kamwitsta »

Head_on_a_Stick wrote: 2023-08-21 15:52 So does /home/kamil/conf/dzen.sh work if you run it from a terminal?
It does, yes.
Head_on_a_Stick wrote: 2023-08-21 15:52 Is there anything in XMonad's configuration that might be overriding `setxkbmap`? And does that command work as expected from a terminal?
No, nothing that I'm aware of. The command works just fine from a terminal.
Head_on_a_Stick wrote: 2023-08-21 15:52 GDM is useless bloat but it can't be causing the problem if the first command in ~/.xsessionrc works.
At first I wasn't entirely sure but I did a little more testing and I can confirm .xsessionrc works. So the question is what overrides the keyboard, and whether dzen gets killed at some point after .xsessionrc is executed, or never run at all.

[EDIT:] After reading the other comment I'll switch to XMobar so dzen, while frustrating, is no longer an issue. Just the keyboard.
Last edited by kamwitsta on 2023-08-22 06:07, edited 2 times in total.

kamwitsta
Posts: 8
Joined: 2015-01-05 21:16

Re: Autostart in XMonad

#7 Post by kamwitsta »

None1975 wrote: 2023-08-21 16:10 For keyboard layout, your should add line to the

Code: Select all

.xsessionrc

Code: Select all

setxkbmap -layout "us,lt,ru" -option "grp:alt_shift_toggle"
This is what I have, and I can confirm .xsessionrc is executed. I think something must be overriding it later, but I can't figure out what it might be.
None1975 wrote: 2023-08-21 16:10 Keep in mind, that .xsessionrc file must be executable. chmod +x .xsessionrc will do that.
It wasn't at first but I fixed it, rebooted, and it still doesn't work.
None1975 wrote: 2023-08-21 16:10 Your should consult the xmonad documentation. For dzen2, your should check this

But you can use more simple solution. It is

Code: Select all

xmobar
[EDIT:] I started playing around with XMobar after reading your comment, I almost got it to do everything I want, and I think with a little more tinkering I can get it to do everything, so thanks, I'm switching. This just leaves the keyboard to fix, then.

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1423
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 47 times
Been thanked: 68 times

Re: Autostart in XMonad

#8 Post by None1975 »

kamwitsta wrote: 2023-08-21 17:45 This just leaves the keyboard to fix, then.
As one workaround, you can try to disable gdm. You can read how to do it here

P.S.

Don't forget the

Code: Select all

exec xmonad 
command, which should be written at the end of the .xsessionrc file
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

kamwitsta
Posts: 8
Joined: 2015-01-05 21:16

Re: Autostart in XMonad

#9 Post by kamwitsta »

None1975 wrote: 2023-08-22 12:02 As one workaround, you can try to disable gdm.
Yes! This worked, thank you so much! I mean, not exactly this. I didn't actually disable gdm in the end but I started digging into it, and I think the one thing that worked was this:

Code: Select all

localectl set-keymap pl_lng
It results in an error during startup, but my layout loads so I guess it's ok. I think it's this bug: https://www.claudiokuenzler.com/blog/12 ... -read-list.

Just in case somebody else also has this problem and is looking for a solution, I also tried this:

Code: Select all

localectl set-x11-keymap pl_lng
echo "pl_lng" > ~/.Xkbmap
and though they did change the output of localectl status, the layout that got loaded was still not the one that I wanted.

Post Reply