Category Archives: Linux

VS code dialogs do not appear in foreground (cinnamon)

That is a common bug in electron applications when they are using GTK (see here and here).

Add to your .bashrc the line:

export GTK_USE_PORTAL=1  

Then edit the menu of the operating system as follows:

  • Right click on the menu
  • Select configure
  • Open the menu editor
  • Select the application
  • Click properties
  • Add the following:
env GTK_USE_PORTAL=1 /usr/share/code/code --unity-launch %F

Screenshots:

Network drives without samba [cifs]

  1. The problem of smb://
  2. Method 1 – without fstab
  3. Method 2 – Using fstab

The problem of smb://

Samba is useful but many programs are not able to handle SMB protocol at a URI. I keep facing problems when using it.

A more compatible way to use network drives is to map them with mount_cifs to a local path. Then all programs will be able to handle files from the network drives. However, the default configuration is that only root user can mount file systems. So it can get a little bit tricky.

Method 1 – without fstab

This method is practically useful only for the current session and it is not permanent. The path is mounted only for the current session. However it is a convenient way to test the network communication.

Firstly, find the user id you are using via the command:

id

Let’s say that the commend returns the number 1000. Then mount the filesystem with the following command:

sudo mkdir /mnt/d
sudo mount.cifs -o rw,username=bob,password=bobpass,uid=1000 //server.local/path /mnt/d

Check that everything is okay. If so you can proceed to the next step to make the changes activate on boot

Method 2 – Using fstab

If you want to have the drives mapped after each reboot then:

  1. chmod +s /sbin/mount.cifs
  2. chmod +s /sbin/umount.cifs
  3. chmod 600 /etc/fstab

Note: In the recent version of Mint, the permissions above are already set correctly, so most probably you can skip the steps above. But it is better to verify the permissions anyway.

Now lets assume that the server is myserver.local

Then, for each share do the following:

  • mkdir /media/localpath
  • nano /etc/fstab
  • add the following line:

//myserver.local/server_path /media/localpath cifs username=u,password=p,uid=1000,iocharset=utf8,vers=3,users 0 0

And you are ready.

You should replace u with the username, p with the password and 1000 your UID. Also use a different localpath for each directory you want to mount.

xbindkeys configuration

Note:

I no more recommend x-bind keys for Linux. If auto-it covers your needs, I believe that you should use it instead.

Table of contents

  1. Goal
  2. Installation
  3. Find the codes of your mouse
  4. Create the script

Goal

The goal is to configure the following:

  1. mouse side button 8 sends Enter
  2. mouse side button 9 sends alt+left (back)
  3. tilde sends ctrl+w (close tab)

For this, we will install:

  • xautomation to scrape keyboard and mouse input
  • x11-utils
  • xdotool: to generate events (optional)
  • xbindkeys: to define keyboard shortcuts

Installation

sudo apt install xautomation
sudo apt install x11-utils
sudo apt install xdotool
sudo apt install xbindkeys

Find the codes of your mouse

We assume in this example that the mouse buttons are 8 and 9, but this may not be your case. So initially we can run xev and check the output once we press those keys on the mo

ButtonRelease event, serial 36, synthetic NO, window 0x2e00001,
    root 0x233, subw 0x0, time 9222464, (94,21), root:(1774,85),
    state 0x10, button 6, same_screen YES

ButtonPress event, serial 36, synthetic NO, window 0x2e00001,
    root 0x233, subw 0x0, time 9223854, (94,21), root:(1774,85),
    state 0x10, button 7, same_screen YES

Create the script

Here is a sample script:

#Back
"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'"
   b:9

#Enter
"xte 'key Return'"
   b:8

# Close tab with tilde
"xte 'keydown Control_L' 'key w' 'keyup Control_L'"
   grave + release

# Disable middle click button
"xclip -i /dev/null"    
    b:2`

You can then use the right alt to print the grave.

To reload the configuration file:

killall -HUP xbindkeys

References:

Ubuntu shell configuration files

/etc/environment

System-wide configuration file used by all users. It is owned by root though, so you need to be an admin user and use sudo to modify it.

This file is read as one of the first configuration files by every shell of every user. Note that it is not a shell script. It is just a configuration file that gets parsed somehow and that may only contain environment variable assignments!

~/.profile

One of your own user’s personal shell initialization scripts. Every user has one and can edit their file without affecting others.

This initialization script is read only by the shells of the user to which it belongs provided that ~/.bash_profile and ~/.bash_login do not exist.

/etc/profile and /etc/profile.d/*.sh

Global initialization scripts that are equivalent to ~/.profile for each user.

The global scripts get executed before the user-specific scripts though; and the main /etc/profile executes all the *.sh scripts in /etc/profile.d/ just before it exits.

References:

https://askubuntu.com/questions/866161/setting-path-variable-in-etc-environment-vs-profile