How do I Ubuntu ? - GNU/Linux

Users browsing this thread: 1 Guest(s)
z3bra
Grey Hair Nixers
Hello folks,

This thread will be a little awkward (for me at least!).
Next monday, I'll have my work laptop reinstalled under stock Ubuntu 21.04, as per my company's policies.

The thing is, I have not used a pre-configured distro in years !
I don't want to use the default Gnome shell, or the default software provided with the distro. I don't mind keeping everything installed though, in case a coworker needs to login on my computer (it'll be connected to the active directory).

So my question will be simple (though the answer might be complex…) :

How do I cleanly change my login session under Ubuntu ?

I basically have my ~/.xsession setup for use with the "xdm" login manager (it is equivalent to an .xinitrc). How do I translate/change it so I can use it under Ubuntu ? I've found that it uses GDM3 and that I'd possibly have to create a .desktop entry to /usr/share/xsessions to launch my own "session script" or whatever. Is that correct ?

Also, Ubuntu 21.04 ships with Wayland by default. Apparently X is still installed, but I'd like to confirm that if anyone has the info.

Help me as the Ubuntu login stack is totally unknown to me, and I don't want to loose too much time setting up my machine next week.

Thanks everyone !
BANGARANG, MOTHERFUCKER
jkl
Long time nixers
Quote: How do I Ubuntu ?

Please don’t.
z3bra
Grey Hair Nixers
I wish I had the choice.
venam
Administrators
(06-08-2021, 12:36 PM)z3bra Wrote: Next monday, I'll have my work laptop reinstalled under stock Ubuntu 21.04, as per my company's policies.

The thing is, I have not used a pre-configured distro in years !

I'm in a similar situation. What I ended up doing is just use it as is and keep it as updated and close to the default install as possible. It's too much of a hassle to go around all that, especially for a machine that isn't mine. Consider it like it was someone else's machine.
z3bra
Grey Hair Nixers
Mmmmh, for me it's my toolbox, and I spend 7+ hours working with it. I just can't convince myself that gnome-shell is the solution to my problems.

To "work" on this issue, I decided to install it ahead of time, and try to change the session. To my surprise, it is fairly easy to do so !

GDM3 (the default login manager) looks into /usr/share/xsessions for possible "sessions" that can be started by a user. You can create your own, which I named "xsession.desktop":

Code:
[Desktop Entry]
Name=Xsession
Comment=Custom Xsession launcher
Exec=/etc/X11/Xsession
Terminal=False
TryExec=/etc/X11/Xsession
Type=Xsession

The /etc/X11/Xsession script is provided by default on a fresh install. Basically, it will run shell scripts provided in /etc/X11/Xsession.d, based on the content of the file /etc/X11/Xsession.options. One of those option is "allow-user-xsession", which will make the Xsession script run "exec $HOME/.xsession" at the end, which works exactly like .xinitrc when you run "startx".

So in the end I just created 2 files:
  • /usr/share/xsessions/xsession.desktop
  • $HOME/.xsession

And I'm back to something I know ! There are still a bunch of thing I need to figure out how to do on Ubuntu (volume management, and the awful combination of "netplan" and "NetworkManager" for network connectivity as an example), but at least I can do so in an environment that I know.
pyratebeard
Long time nixers
As much as I don't like Ubuntu and Gnome Shell it is nice that you are running native Linux. My current work laptop is running my Linux distro in a VM.

My company is toying with allowing Ubuntu laptops as well, so I will be bookmarking your post for future reference. Thanks for figuring it out for me!

You should keep us updated with how you find using Ubuntu, I for one would be interested.

I could do with a shot of rum right now.
zge
Long time nixers
I don't get what the issue is, why not just work in the default terminal?
z3bra
Grey Hair Nixers
Because my usage of a linux distribution goes beyond typing stuff at a shell. The softwares I'm used to is different from what's shipped by default on Ubuntu.
zge
Long time nixers
So then statically compile all you need, bring it along on a USB stick and store it in a local bin directory, or is that not allowed? What specifically are you not used to?
z3bra
Grey Hair Nixers
Window management mostly. And some application launchers that I use (xmenu, sxhkd, dmenu) for which I need the ability to start them when the session starts.
In this regard, there are also a lot of things in the default Gnome shell that prevent my own applications to work as expected. A lot of things that I don't use also.

In a simple way: I don't like the Gnome shell session and want to set it up the way I like.
freem
Nixers
Hum... can't you just summon xinit from a TTY, and use ":1" instead of ":0"?
GDM might keep it's :0, but nothing should prevent you from running a different Xorg session, right?

Of course, here, I assume you're using Xorg, and not wayland. I have no idea if both can coexist and run aside on the same system, nor if ubuntu relies on wayland by default.
z3bra
Grey Hair Nixers
Ubuntu default's session is Xorg, but wayland is supported also.

I didn't want to "hack" around the distro, that is, leave GDM running, change TTY and login+xinit. If I'm stuck with a distro, I might just as well use that to my advantage and learn how to use it.

Just as a note, I'm now fully up and running on my very own session. I got everything setup just as I want, and it was much easier than I initially though. I'll make a separate post to expose my solution !
z3bra
Grey Hair Nixers
So I finally managed to do everything I wanted, and get my very own configuration working. There are multiple key points, so I'll list them here:

X.org session startup

Ubuntu 21.04 ships with GDM3 as its default session manager. On the login screen, you can spot a small gear icon that lets you select the type of session you want. There are 2 choices by default: "Ubuntu" and "Ubuntu on Xorg". I decided to add a 3rd entry: "xsession".

Doing that was fairly easy. I created the following file as "/usr/share/xsession/xsession.desktop":
Code:
[Desktop Entry]
Name=xsession
Comment=Custom Xsession launcher
Exec=/etc/X11/Xsession
Terminal=False
TryExec=/etc/X11/Xsession
Type=Xsession

Upon doing that, and selecting the entry on the login screen, GDM will run the "/etc/X11/Xsession" script, which (among other things) runs the "$HOME/.xsession" script, which you can use to start your session, just like you would do with ".xinitrc".

X.org session

This part was pretty easy. Now that I narrowed my whole session down to a single script, writing that script was easy:

Code:
#!/bin/sh
# $HOME/.xsession

xrdb -merge $HOME/.config/xrdb/ssh-askpass
xidle -timeout 300 -program $HOME/.local/bin/lock &
xsetroot -cursor_name left_ptr
bgs -z $HOME/.bg.jpg

sxhkd -m1 -r /dev/null & # keybinds
glazier & # window management
ewmh & # EWMH support
picom & # compositing
x-widgets & # status bars
rootmenu & # right-click menu (launcher)
safe -rkp '' & # password manager

x-wait # X session holder (basically an infinite loop)

# cleanup session on exit (kill password manager)
kill -TERM $SAFE_PID
rm -f $SAFE_SOCK

Something worth mentioning about /etc/X11/Xsession: by default it tries to source "$HOME/.xsessionrc" before running your script, so it acts like $HOME/.profile. I use it to set my environment variables that are specific to the X session (mostly related to password manager).

Networking

This was the most complex part for me. It's probably because networking is a big part of my job, but I want my networking setup exactly the way I want it. My laptop (like most!) has 2 interfaces: wired and wireless. And I want to be able to seamlessly transition between both, and without disconnection. By default a different IP is assigned for each interface, and when you "switch" connection, you switch IP as well, thus killing all active connections.

I used to run an active/passive bonded connection on my previous debian install: it's a virtual interface that aggregates both the wired and wifi connection, and activate them "on-demand". The mac address of the bonding is that of the primary interface (in my case, the wired one).
This means that when I unplug the cable, the wifi becomes the primary interface, but keeps my current DHCP lease as the MAC address of the bonding interface remains the same. This worked great, and I wanted to replicate it under ubuntu.

Unfortunately, Ubuntu dropped usage on /etc/network/interfaces with release 18.04 I think, so I couldn't just copy my debian config there. The "official" way of configuring the network under Ubuntu seems to be using NetworkManager, and its "nmcli" tool. I have yet to test if I can just drop a file in /etc/NetworkManager to make it work, but for now, I had to do it on the cli (note: bonding a wifi interface is unsupported by NetworkManager, so you need to create a bond with multiple connections: wired, wifi1, wifi2, wifi3, … and add wifi to the bonding as you encounter them. This is ugly, but it works !

Code:
# create bonding interface
nmcli con add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=100,primary=$WIRED"

# add wired interface to the bond
nmcli con add type bond-slave ifname $WIRED master bond0

# add new wifi connection to the bond (this command is wrapped in a "wifi-add" script, to add more wifi connections as time goes)
nmcli cond add type wifi con-name "bond-wifi-$SSID" ifname $WIFI master bond0 ssid "$SSID" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$WPA_KEY"

And that's it ! I hope this would help someone someday. If not, I learnt something new at least, which is nice.
pyratebeard
Long time nixers
thanks for that z3bra, it looks more likely that we will be able to get Ubuntu laptops in work so this is handy to know