How to create a custom desktop using the .Xsession file.
This is an example of an .Xsession file, this will provide a custom desktop environment.
#!/bin/sh # Load your X Resource defaults, if you have them. if [ -f $HOME/.Xdefaults ]; then xrdb -merge $HOME/.Xdefaults fi xterm & tint2 & nm-applet & gkrellm & # Get just the first part of the machine's full hostname, I like # this as an xload label. Note the BACKquotes used here! SHORTHOST=`hostname | sed 's/\..*//'` # Display a graph of the system load xload -geometry 70x70-1+68 -fg SteelBlue -bg black -hl blue -fn fixed -label $SHORTHOST & # Launch an xterm so we have someplace to type. xterm -bg black -fg green -cr white -ls -geometry 80x25+0+0 & xsetroot -solid DarkSlateGrey exec startfluxbox
#!/bin/sh # Load your X Resource defaults, if you have them. if [ -f $HOME/.Xdefaults ]; then xrdb -merge $HOME/.Xdefaults fi xterm & tint2 & nm-applet & gkrellm & # Get just the first part of the machine’s full hostname, I like # this as an xload label. Note the BACKquotes used here! SHORTHOST=`hostname | sed ‘s/\..*//’` # Display a graph of the system load xload -geometry 70×70-1+68 -fg SteelBlue -bg black -hl blue -fn fixed -label $SHORTHOST & # Launch an xterm so we have someplace to type. xterm -bg black -fg green -cr white -ls -geometry 80×25+0+0 & xsetroot -solid DarkSlateGrey exec startfluxbox
This is how you create a custom desktop that will suit your workflow. With the Lightdm desktop login manager, choose the Default Xsession option and this will read the .Xsession file and load your desktop. This is an age old method of creating a custom desktop layout.
Use this command to create a custom .Xsession file.
Then open the file in an editor such as VIM to add whatever you need to setup your desktop.
#1 How to create a custom Linux GUI (Desktop) from scratch
The base Ubuntu I installed is the Ubuntu MinimalCD. You can find the ISO here:
To install all the packages I’m using “sudo apt install” and the packages I install, in the order I install them are:
lightdm
openbox-gnome-session
openbox
gnome-terminal
obmenu
gedit
tint2
docky
nitrogen
ubuntu-wallpapers
pcmanfm
lxappearance
xcompmgr
firefox
pavucontrol
volti
gconf-editor
The file you want to create/edit for openbox autostart commands is located at ~/.config/openbox/autostart.sh
The file you want to create/edit to automatically login is located at /etc/lightdm/lightdm.conf (Must be root to edit/create this file).
While this is “almost” from scratch, I have no intention of truly going completely from scratch, AKA, compiling the kernel etc. So many things go wrong! LOL
48 Comments
Some additions from June 15th 2018:
1. If you don’t see «manual package selection» in installation, select none of the packages and Continue.
2. When setup is complete click Yes to GRUB Boot setting. If you dont boot into the terminal after restarting the VM. Go to settings > Motherboard and uncheck Floppy Disk & Disk drive. You will then reach the same screen as Dorian above.
3. After installing gnome-terminal, I received «Failed to start session» too. Changing to OpenBox instead worked
And thanks for great video!
How to Easily Create a Custom Lightweight Desktop Environment
Gnome and KDE are great – they give you a beautiful desktop with all the tools and utilities you need. On either system, you’ll find a solid window manager, desktop icons, a panel full of applets, the works. That’s all well and good for your average desktop PC, but what if you need something lighter, faster, or cleaner in appearance? You could try a smaller desktop environment like XFCE or go with something ultra-slim like Openbox or WindowMaker. On the other hand, you could get exactly what you want, no more no less, by combining individual pieces together into your own custom desktop environment.
How?
When you run Gnome, you’re not running a single application. Gnome launches Metacity (optionally Compiz) to handle window management, gnome-panel to serve as the panel and menu system, and various applets and tools for things like power management and Bluetooth support. Each of these is independent of the others and can be replaced or launched on its own.
What we’ll be doing today is specifying our own list of applications (window manager, dock, etc) to run on login, completely bypassing the likes of Gnome and KDE in favor of our custom apps. There are a few methods of achieving this, and the one demonstrated here was chosen to be functional, simple, and not very distribution-specific.
Designing Your Desktop
To create a functional DE, you’ll need a few basic parts:
- Window manager (Metacity, Compiz, etc)
- Application launcher (Gnome-Do, Kupfer, etc)
- Panel/Dock (Docky, Cairo Dock, PyPanel, etc)
- Wallpaper manager (bsetroot, hsetroot, etc)
- Optional panel applets, desktop widgets, etc
This guide will use Compiz, Gnome-Do, Cairo Dock (with applets), and hsetroot to achieve all the needed functionality. Using Compiz as the base window manager gives us the full set of Compiz plugins like Expo and Zoom. All those packages should be available in the standard repositories of most distributions. Ubuntu users can fetch them from the Ubuntu Software Center or with the terminal command:
sudo apt-get install compiz compiz-plugins gnome-do cairo-dock hsetroot
Most of these applications have been discussed in detail on MakeTechEasier. Use our search box to gather more information on which tool is the best for your needs.
Some other usable setups could include dropping the dock/panel entirely and using Gnome-Do for all app launching needs, or adding something like Conky or Google Desktop for system monitoring.
Creating the List
Now that you’ve got an application chosen for each of the roles above, we can begin creating a list so that they will be run on login. Begin by opening any text editor of your choice, and writing out the names of the programs to be run. End each of the lines (except the last) with a &. This symbol tells Linux to run the program in the background and move on to the next item. Without the &, it would run the first line and wait until that program was completed before running the next. That could, for example, prevent the dock from loading until after the window manager is closed – clearly not what we want.
When finished, save the file to any directory you choose (your home is fine) and take note of the file’s name and location. As my name is Josh, I have the file saved in /home/josh/customDE.sh.
Adding to GDM list
In what I’m sure must be amazing coincidence, we recently wrote a detailed guide on precisely how to edit the GDM Sessions list to let you launch your own desktop environment.
In short, you’ll want to (as root) create a new file in the /usr/share/xsessions directory. The file should end with the .desktop extension, and follow a template similar to the following:
The only really important lines for this scenario are Name and Exec. Name must uniquely identify your DE so that you can recognize it in the GDM Sessions list. Exec must be the name of the file we created in the previous step, such as customDE.sh.
Save the file as /usr/share/xsessions/custom.desktop. Next time you logout, you’ll see your entry in the Sessions list in GDM.
Conclusion
If you’ve followed each of these steps, you created a list of applications you wanted in your DE, saved that list (with appropriate ampersands) into a script, then created a launcher in /usr/share/xsessions to start that script from GDM. Hopefully, your choices have left you with a feature-complete and beautiful desktop. Not only should it meet your specific needs, but there’s a good chance it’ll be far more responsive than a monolithic desktop system like Gnome.
If you’ve got desktop customization stories or suggestions for how to create your own, let us know in the comments!
Josh Price is a senior MakeTechEasier writer and owner of Rain Dog Software
Our latest tutorials delivered straight to your inbox