20 articles

How to quickly and easily mount an USB drive as a regular user using the command line

To mount my USB drive, I was using the traditional sudo mount /dev/sdXY /path/to/mountpoint. But because I was mounting as root, I had to prefix every operation with sudo. So how to mount it as a regular user ?

Simply using udisks ($ sudo pacman -S udisks2), which is used by gvfs and various file managers:

$ udisks --mount /dev/sdd1
Mounted /org/freedesktop/UDisks/devices/sdd1 at /media/KINGSTON

To find your device:

$ sudo fdisk -l

Now I can execute basic cp, mv... operations on /media/KINGSTON without having to prefix them with sudo.

How to mount from command line like the Nautilus does?

How to import some Linux-like behaviors into Windows ?

Sometimes using Windows is required, for professional reasons, gaming, nostalgia... (nah, just kidding). Then I quickly find myself moving my mouse from a window to another and start typing, expecting that the window I'm typing in has the focus. Or I select a text and click the middle button of my mouse, expecting to paste that text... If you recognize yourself in those expectations, read on...

Select to copy, middle-click to paste

Download True X-Mouse. Just execute it to enable the behaviours. An icon will be displayed in the system tray.

True X-Mouse icon in the system tray

This also enables focus following the mouse pointer without delay.

How to make the focus follow the mouse without using third-party software

I found this tip before reading about True X-Mouse.

  1. Open Control Panel
  2. Open Ease of Access Center
  3. Click Make the mouse easier to use
  4. Check the option Activate a window by hovering over it with the mouse
  5. Click OK.

Activating focus follows mouse via Control Panel

This will give the focus to the window currently under your mouse pointer, great ! Or not... Two things could still bother you: that feature has a delay and it also raises the focused window. To fix that (or "when Windows stops being user-friendly") :

Stop raising focused windows

  1. Open the Registry Editor (regedit.exe)
  2. Select HKEY_CURRENT_USER\Control Panel\Desktop
  3. Double click on UserPreferencesMask in the right pane. These are hexadecimal numbers, which relate to many visual effects. We have to subtract 40 bits from the first hexadecimal value (in my case the first two numbers after 0000). Don't worry, you can do that with Windows Calculator. Set it to Programmer mode in the View menu, then enter the first value - 40. In my case, DF - 40 = 9F. So replace DF with 9F. Be careful not to modify any other number.
  4. Click OK.

Disable window auto-raise via regedit

Faster focus

  1. Still in HKEY_CURRENT_USER\Control Panel\Desktop, double click on ActiveWndTrkTimeout in the right pane. Here you can display it in decimal to directly change the time in milliseconds. Set it to the duration you want: 0, 500 (1/2 second), 1000 (1 second), etc.
  2. Click OK.

Make moving focus faster

When you are done, log off and back in for the settings to take effect.


Simple fast application launcher

Another feature I missed was polybar which I use in my i3 environment. Download and install Launchy. It is free, cross-platform and open-source.

Launchy main window

Press Alt-Space to open it. Click the wheel in the upper right to open its settings. The Catalog tab lets you customize the directories inside which Launchy look for executables. Click the rescan button after updating the directories list. Go to the Skins tab to try other looks.

Launchy settings

[PCManFM] Unable to find or create trash directory

This error happened when I tried to trash files located on a secondary drive, which is automatically mounted at startup in my /etc/fstab.

To fix this, I manually created a hidden .Trash-1000 folder at the root of the mounted folder, and made it belong to my user:

sudo mkdir /path-to-mounted-drive/.Trash-1000
sudo chown your-username .Trash-1000

1000 is the uid of my user. This is the default value but you can find yours with the id command:

$ id                                               
uid=1000(didier) gid=100(users) groups=100(users)[...]

Alt+Insert shortcut not working with Fn key in Android Studio (and maybe elsewhere)

I have a TypeMatrix keyboard with quite a few keys requiring pressing the Fn key first.

A TypeMatrix keyboard

Insert is one of them. So if I want to use a shortcut like Alt+Insert, I usually just need to type Fn+Alt+Insert. But it does not work in Android Studio1 2, where I had to add a custom mapping. It appears that Fn+Alt is recognized as Alt Gr, which explains why the default shortcut was not triggered.

To add a custom mapping in Android Studio, go to File > Settings. In the popup window, click Keymap on the left and type generate in the search field. This will display the current mapping associated with the Generate... command. Double click on it to display the Edit Shortcuts menu and then choose Add Keyboard Shortcut to finally enter your custom shortcut.

Add a custom mapping in Android Studio

1 It happens I have noticed this while using Android Studio, but it probably happens in other software too.
2 I am currently using version 3.1.2.

[Bluetooth] Failed to connect: org.bluez.Error.Failed

Error after removing then reconnecting my Bluetooth dongle. The culprit was PulseAudio, which needed to be restarted:

$ pulseaudio -k
# re-do bluetoothctl stuff (may not be needed)
$ pulseaudio --start