Skip to content

Instantly share code, notes, and snippets.

@medwards
Last active September 10, 2022 23:01
Show Gist options
  • Save medwards/a36eda6daedaa469050057bd810d83dc to your computer and use it in GitHub Desktop.
Save medwards/a36eda6daedaa469050057bd810d83dc to your computer and use it in GitHub Desktop.

Xmonad + Gnome integration for Ubuntu 19.10

The guide at https://wiki.haskell.org/Xmonad/Using_xmonad_in_Gnome#Ubuntu is increasingly out of date and was already pretty flaky by Ubuntu 16-18. This guide is for Ubuntu 19.10.

I'll try to include some additional context for whats going on so that when things change again it should hopefully not leave you completely lost.

What I want (AKA you can ignore this if your response isn't "Just don't use xmonad + gnome")

Some folks wonder why I want this setup as a precursor to actually figuring it out. That's a valid question even if all the questioners aren't willing to engage in my responses. I've listed the core things I'm trying to get out of this setup below, but if you have honest-to-good-ness equivalents to these requirements then I would love to ditch this setup for something easier to maintain:

I absolutely want nm-applet and the calendar indicator from gnome. The sound indicator is also a nice side benefit and I don't know how well dbus notifications work without the gnome ecosystem. Oh, and I like gnome-terminal. I don't need the Applications menu (I like dmrun) or the workspaces bar but they come with this setup and I don't mind having them. If you can get me nm-applet, and a good sound/calendar indicator then I would happily ditch this complexity.

You might similarly ask why not another TWM: help me figure out how to get window layout schemes the same as xmonad, with no gutters, and the same keypresses and I'm on board. However, despite xmonad's configs being IN HASKELL it still seems painful to correctly configure the TWM alternatives I've tried. Plus I want my indicators!

Actual Stuff You Need To Do

/usr/share/xsessions/gnome-flashback-xmonad.desktop
This file should already exist but is completely unmaintained and hasn't worked for years. Mine is so hacked up I can't even tell you what the base-state looks like nowadays

Up to Ubuntu 18 you wanted to add

Exec=/usr/lib/gnome-session/run-systemd-session gnome-session-x11@gnome-flashback-metacity.target
TryExec=xmonad

(which is how gnome-flashback-metacity pretty much worked) otherwise it wouldn't work or you wouldn't get all the indicators

gnome-session now has more sophisticated systemd support and you just need

Exec=gnome-session --systemd --session=gnome-flashback-xmonad --disable-acceleration-check

This won't work out of the box so you need to add a bunch of additional stuff

/usr/share/gnome-session/sessions/gnome-flashback-xmonad.session
Some component needs to know what indicator services you need so you put it in this file, easiest is to copy /usr/share/gnome-session/sessions/gnome-flashback-metacity.session and replace metacity with xmonad.

/lib/systemd/user/gnome-session-x11@gnome-flashback-xmonad.target
In Ubuntu 18 you could just hijack the metacity target, but I wasn't able to get this to work. So copy from /lib/systemd/user/gnome-session-x11@gnome-flashback-metacity.target into the gnome-xmonad target. No changes necessary, I have no idea what this really does.

After this it works mostly as advertised! Some annoying things have crept in over the years:

  • gnome-terminal now uses some new rendering stuff for its titlebar which means it won't be hidden.
    • gsettings set org.gnome.Terminal.Legacy.Settings headerbar "@mb false" worked for me.
  • In Ubuntu 18 xmonad stopped honouring the gnome-panel (this seemed deterministic by setup, some of my systems had this problem, some did not).
  • In Ubuntu 19 gnome isn't using the same theme as metacity. You can even load up gnome-flashback-metacity and its in the dark ubuntu theme but gnome-flashback-xmonad is in some ugly light theme.
    • Wasn't able to fix it, but rebooting made it go away!
  • window layout changing isn't working (ie to switch from columns to rows)
    • Almost certainly some default Gnome or Ubuntu keybindings eating the key (In older versions of Ubuntu I found something in org.gnome.settings-daemon.plugins.media-keys but I think that has changed over time)
  • In Ubuntu 20.04 gnome-panel started disappearing
    • gnome-panel --replace will bring it back
    • regolith-linux/regolith-desktop#276 (comment) has a reliable fix but you lose desktop icons (sounds fine)
    • gsettings set org.gnome.gnome-flashback desktop false
    • gsettings set org.gnome.gnome-flashback root-background true
  • In Ubuntu 20.04 gnome-panel wasn't dark any more:
    • gsettings set org.gnome.desktop.interface icon-theme "ubuntu-mono-dark"
    • gsettings set org.gnome.desktop.interface gtk-theme Yaru-dark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment