Showing posts with label LUbuntu. Show all posts
Showing posts with label LUbuntu. Show all posts

15/07/2020

[bash] Extract all distinct lines from file

Using a combination of cut and uniq, it is possible to extract all distinct lines from a given file:

cut -d\; -f1 file.txt | uniq


It is optionally possible to sort the file as well adding sort to the command:


cut -d\; -f1 file.txt | sort | uniq

[bash] Extract characters before marker from all lines in a file with sed

Using sed, it is possible to quickly extract all characters before a given marker from all lines in a file with:

sed 's/MARKER.*//' file.txt

29/04/2020

[Docker] Move docker directory to different location on NTFS filesystem

The default location of docker files (images, volumes, networks, etc) on most distributions is /var/lib/docker

This can be easily changed with the daemon.json configuration file.

First stop the docker service and make sure it is completely stopped.

You can now edit or create the configuration file under /etc/docker folder. In there, you can specify a new location for the docker files with the graph attribute:

{
   "graph": "/path/to/new/docker_folder"
}



You can then copy ALL the content to the new location or let docker recreate everything from scratch there.

WARNING: if the new location is on a different filesystem you might need to change the storage driver AND existing data might become inaccessible (it will remain on the filesystem though)

To set a new storage driver, set the storage-driver attribute as well (example for NTFS):

{
   "graph": "/path/to/new/docker_folder",
   "storage-driver": "vfs"
}

28/04/2020

[GNOME] Create application shortcut that can be added to favorites

Some applications you install come as archives that you extract in a desired location. However, not all come with an installer that takes care of creating the proper application entries, leaving the task to the user.

You can add a shortcut for any application by creating a file APPLICATION_NAME.desktop under /usr/share/applications and adding this content:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Terminal=false
Categories=OPTIONAL_CATEGORY_LIST

GenericName=APPLICATION_NAME
Comment=OPTIONAL_COMMENT
Name=APPLICATION_NAME
Path=FULL_PATH_TO_APPLICATION_FOLDER
Exec=FULL_PATH_TO_APPLICATION_EXECUTABLE

Icon=OPTIONAL_FULL_PATH_TO_ICON

StartupWMClass=APPLICATION_WM_CLASS


[Linux] Find WM_CLASS value for an application

In order to group application windows together, the WMClass and WMInstance attributes have been specified in the Inter-Client Communication Conventions Manual for X server 11.

Long story short, they are two strings that are used to associate application windows to a specific application, they can be set by the application (WMClass) or the user (WMInstance).

They are very useful especially for those applications that are customizations or based on existing tools, which alone would have a different value (eg Java or Eclipse based apps).

Finding the value for a window is as simple as opening a terminal and running:

xprop

Then clicking on the desired window


25/04/2020

[Linux] Custom keyboard layout QWERTZ to QWERTY

We already saw how to customize a keyboard layout on Windows, now it's the turn of Linux, using XKB for Xorg.

Remapping keys is as simple as editing a text file. You will find all available layouts under /usr/share/X11/xkb/symbols, you can use them as basis for a new layout or directly edit them.

Pick the layout you want to change (maybe make a backup first), then invert the VALUES ONLY of the two lines containing the lower and uppercase z and y, then save.

You will need to restart X server and the changes will be in effect.

18/03/2019

[Ubuntu] Install Microsoft fonts

Most of the world uses Microsoft Windows and Office, therefore it might be sometimes necessary to generate documents using Microsoft fonts, which of course are only available on Windows.

For Ubuntu, the ttf-mscorefonts-installer package contains SOME of those fonts, simply install it and you can start using them AFTER regenerating the font cache with fc-cache

15/08/2018

[Ubuntu] Revert kernel back to older version

Intro story: So much luck in a single day.

I always keep only 2 kernel versions after every update, so that I can boot back if something goes wrong. This usually helps, except today I decided to upgrade my Ubuntu from 16.04 to 18.04 since I like spending my nights fixing stuff after unnecessary upgrades, but hey, the future is there.

So I first fully updated my current installation (1st kernel bump), then migrated to the new one (2nd kernel bump) and it turns out I got two 4.15 kernels, with only different minor version.

Double interesting, my wireless card:

02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter

apparently has issues (read: bug) with kernel 4.15 preventing it from working at all (not even connected to the router), and even more interesting, on one version it can actually only connect to websites under google.com domain..

Anyway, quick fix was to revert back my kernel, here is how for future me to remember:
  1. go to http://kernel.ubuntu.com/~kernel-ppa/mainline/ and download in the same folder: linux-headers-VERSION-generic-XXX_SYSTEM.deb, linux-headers-VERSION_all.deb, linux-image-VERSION-generic-XXX_SYSTEM.deb for your system, eg I have 64 bit system and got amd64 files
  2. install them by going into the folder where you downloaded them, make sure there are only those three .deb files and run: sudo dpkg -i *.deb
  3. restart the system, then press SHIFT at boot to enter the GRUB choices, then check from the top line (number 0) to the line of your kernel version. If your installation has the "Advanced" menu entry and does not display all kernels, go there and do the same counting. We need this to set a default GRUB entry to always boot in this kernel
  4. edit /etc/default/grub and change the value of GRUB_DEFAULT to the number you counted OR to (exactly as shown) "1>N" if you have the "Advanced" menu option. This means you want to boot into the Nth entry (starting from 0) under the "Advanced" menu. Also set GRUB_TIMEOUT to some value in seconds that's more than 1, to have some time to block the boot process in case of mistakes
  5. run sudo update-grub and you are set
Note that this is a TEMPORARY fix, you would not want to have a fully updated system run on an older version of the kernel, mainly because some obscure dependency or feature might be missing/not working, therefore check back periodically to see if your issue has been addressed and try the latest kernel version out!


04/06/2016

[Ubuntu] fix plymouthd splash load boot error

We sometimes struggle to keep up with all the things that are constantly evolving, so I like how Ubuntu still gives us reassurances that some important features are cemented in its core, such as the plymouthd boot splash error: "plymouthd could not load boot splash: could not access needed shared library".

Just update the kernel and you might be the lucky winner that gets stuck at boot.

The fix is easy and fast enough though. The immediate thing you can try is to edit the boot options when GRUB presents you the list of boot choices:
  1. select the Ubuntu line corresponding to the kernel you want to boot and press the e key
  2. find the line where the ro quiet splash parameters are set (unless you have already changed them in the past), but then you know which line I'm talking about anyway ;)
  3. remove the splash parameter
  4. add at the end of the line: gfxpayload=keep
  5. press F10 to boot

23/05/2016

[LXDE] LUbuntu desktop composition enable key shortcuts

The openbox window manager bundled with LUbuntu is powerful enough to provide the same functionality as similar applications, but it's unfortunately delivered with a barebone configuration.

One functionality I'm missing it's the ability to drag, resize and snap windows to desktop sides. Luckily I found code pieces to enable such functionality, albeit not via mouse controls but key combinations; to add it, simply edit ~/.config/openbox/lubuntu-rc.xml and add under the line
 <chainQuitKey>C-g</chainQuitKey>  

this code:
 <keybind key="W-Left">    # HalfLeftScreen  
  <action name="UnmaximizeFull"/>  
  <action name="MoveResizeTo">  
   <x>0</x>  
   <y>0</y>  
   <height>100%</height>  
   <width>50%</width>  
  </action>  
 </keybind>  
 <keybind key="W-Right">    # HalfRightScreen  
  <action name="UnmaximizeFull"/>  
  <action name="MoveResizeTo">  
   <x>-0</x>  
   <y>0</y>  
   <height>100%</height>  
   <width>50%</width>  
  </action>  
 </keybind>  

Then just do an openbox --restart

You can now use the Windows key (Super) and the right or left arrow to snap the currently active window to the right or left side of the screen, at 50% width

Note: apparently openbox is reserving some space for the toolbar on the bottom of the screen, so even declaring 100% height will NOT fill all available space after resizing.

09/04/2016

[LXDE] LUbuntu change clock format

Again, out of all the nice to have stuff people left out of LXDE, an easy way to edit the clock date and time format is missing.

Luckily, the tinkering required is minimal. Right click on the clock and select "Digital Clock" Settings, then enter the desired format in the Clock Format section.

For example:

%a %d %b %R

would result in:

[3 letters day name] [day number] [3 letters month name] [hours:minutes in 24 hours format]

eg:

Sat 09 Apr 16:17

[LXDE] LUbuntu change keyboard shortcuts

LXDE is extremely lightweight, maybe a bit too much, in the sense that they left out some user-friendly portions such as an easy graphical way to edit keyboard shortcuts.

You can still do it with a bit of tinkering, by editing the ~//.config/openbox/lxde-rc.xml file.

Remember that this syntax applies:

C = CTRL key
S = SHIFT key
A = ALT key
W = Windows key

[LXDE] LUbuntu auto num lock on boot

If you experience issues with the keyboard num lock not being automatically activated at boot or after lock screen wakeup in LXDE, try this:

- install numlockx:

sudo apt-get install numlockx

- edit /etc/xdg/lubuntu/lxdm/lxdm.conf and find numlock line then remove the comment and enable it:

numlock=1

- edit /etc/lightdm/lightdm.conf and add this line:

greeter-setup-script=/usr/bin/numlockx on




[LXDE] Lock screen in LUbuntu via shortcut

LUbuntu users may encounter a bug that prevents them from locking the screen either from command line or keyboard shortcut.

In my case, solving it was quite easy:

First install lxlock and light-locker, you might already have them:

sudo apt-get install lxlock light-locker

Then edit ~//.config/openbox/lubuntu-rc.xml and modify or add the lockscreen section:

  <!-- Lock the screen on W + L-->  
  <keybind key="W-L">  
   <action name="Execute">  
    <command>lxlock</command>  
   </action>  
 </keybind>  


Finally restart openbox:

openbox --restart