<< back

Linux tips & tricks

Chage GRUB background

Theoretically, this should be as easy as modifying /etc/default/grub file, adding GRUB_BACKGROUND=/path-to-image and executing sudo update-grub afterwards.

However, in my case (Sparky Linux, based on Debian) there were two "layers of abstraction" I had to jump over.

The output file, result of uptage-grub command is stored in /boot/grub/grub.cfg. Upon inspecting I've found that it uses /etc/grub.d/06_sparky_theme as a source of the background image. This is highly dependend on the distro, so YMMV. You might find set_background_image directive in that file, which should get you there, except that it didn't... (ran update-grub and checked grub.cfg output).

Turns out that "sparky theme" file is using a script, stored in /usr/share/desktop-base/sparky_grub_background.sh which sets the background image. IMHO it's quite convoluted, but after changing the path in there and running update-grub I finally got my image set. In Sparky the images are stored in /opt/artwork, which requires sudo access to copy to.

How to change boot (OS loading) screen?

In case of Sparky the splash is managed by Plymouth which keeps its configuration in /etc/plymouth/plymouthd.conf. The themes are stored in /usr/share/plymouth/themes/. Therefore it's necessary to either edit an existing theme or create a new one. There's an interesting template on GitHub, however I am not sure if it works as I've resorted to changing the default /usr/share/plymouth/themes/sparky-blue/sparky-blue.script to point to a different image saved in the theme's directory. If I'm not mistaken you have to do sudo update-initramfs -u after changing the theme.

How to change default resolution in Openbox?

In my Sparky configuration the resolution kept resetting on each reboot. So annoying! Thankfully, there are autostart scripts that let you run a command to set a resolution to whichever one you want. There's a global autostart at /etc/xdg/openbox/autostart and user-specific one at ~/.config/openbox/autostart. All you need to do is add a call to xrandr (assuming you're on X, not Wayland), for example like this xrandr --output eDP-1 --mode 1680x1050 (that's the name for my laptop's built-in screen, might be different for a external display).

Show package details and dependencies

# Shows details of "gedit" package
apt-cache show gedit

# Shows what packaged "gedit" depends on
apt depends gedit

# Shows which packages depend on "gedit"
apt rdepends gedit

# Explains why package "gedit" is installed, e.g. "installed manaully"
aptitude why gedit

You can also find packages in Debian's package index.

How to setup global gitignore?

Create a .gitignore file in your home directory and then add it to global configuration with git config --global core.excludesFile '~/.gitignore'.

How to select a primary screen?

First, we need to get the list of available monitors and their names with xrandr --listmonitors. You can also use xrandr without any arguments, but the output is quite verbose. Usually the laptop's built-in screen is called eDP-1, and is by default the primary one. To change that, execute xrandr --output HDMI-2 --primary (replace the output name with desired one). Why is this useful? Well, for example a launcher/menu (like jgmenu) tends to show up on the primary one, similar with global shortcuts on Openbox that launch terminal or file manager.

How to swap Caps Lock and Control keys?

And why would you even want to do that? Well, maybe lots of the keyboard shortcuts that you're using are based around CTRL key and after many hours of work you feel not only mental, but physical pain (so-called "Emacs pinky"). It could be as simple as executing setxkbmap -option "ctrl:nocaps" but sadly this configuration won't survive the reboot. Instead, edit /etc/default/keyboard and add/modify XKBOPTIONS="ctrl:swapcaps" option. NB: this works only on Debian-based systems!

How to get basic window tiling (snapping) in Openbox?

You can add this to your ~/.config/openbox/rc.xml file to be able to move windows to left and right halves of the screen with Super + Left/Right keys. As a bonus, you can maximize it (Super + Up) or put it in original place (Super + Down).

<keybind key="W-Left"> <action name="Unmaximize" /> <action name="MoveResizeTo"> <x>0</x> <y>0</y> <width>50%</width> <height>100%</height> </action> </keybind> <keybind key="W-Right"> <action name="Unmaximize" /> <action name="MoveResizeTo"> <x>50%</x> <y>0</y> <width>50%</width> <height>100%</height> </action> </keybind> <keybind key="W-Up"> <action name="Maximize" /> <action name="Undecorate" /> </keybind> <keybind key="W-Down"> <action name="Unmaximize" /> <action name="Decorate" /> </keybind>

If you want to extend it, take a look at the list of available actions and general rules for bindings. There's a great blog post by Thomas Hunter II that offers much comprehensive solution, or a simpler variant from this reddit post.

To apply the changes execute openbox --reconfigure or --restart if that didn't work.

<< back