Open phpstorm:// uri:s using xdg-open in Linux

I couldn’t get this to work properly on my Linux box; so I wrote a litte script that parses the uri scheme and launches phpstorm.


$arg = $argv[1];
$parts = parse_url($arg);
$query = $parts['query'];
parse_str($query, $output);
$file = $output['file'];
$line = $output['line'];
$cmd = '/usr/bin/phpstorm --line ' . $line . ' ' . $file;

Then create a new file in ~/.local/share/applications/phpstorm-protocol.desktop

[Desktop Entry]
Name=PhpStorm Protocol Handler
Exec=/path/to/the/script %u

Make it available, run:


and then register it with xdg-open

xdg-mime default phpstorm-protocol.desktop x-scheme-handler/phpstorm

Now, when you click a phpstorm:// link in your browser choose to open it with xdg-open.

Firefox lpr workaround

For some reason unknown to mankind, Firefox doesn’t allow you to print via lpr any more.

It used to be that if you had lpr enabled on the line gtk-print-backends= in your ~/.config/gtk-3.0/settings.ini, you would be able to print directly to lpr.

But recently (I’m using Firefox 60 at the moment) this doesn’t work.

After this workaround I only kept ”file” in my settings.ini.



My workaround was to create a simple script that watches a folder, if it finds a PDF, print it using lpr and then remove the file.

Then a simple systemd user script to get it running in the background.

The ”printy” script

Most beautiful bash script ever.

#!/usr/bin/env bash


mkdir -p "$PRINTDIR"

while true; do 
  sleep 2

  for file in "$PRINTDIR"/*.pdf; do
    if [ -f "$file" ]; then
      cat "$file" | lpr -l && rm "$file"

Change PRINTDIR to where you’ll print PDF:s to from Firefox.

systemd unit script

Description=Fucked up Firefox printing workaround script



Save file in ~/.config/systemd/user/printy.service.

To keep the script running after you login/logout and reboot. Enable ”lingering” in systemd.

As root, run: systemctl enable-linger ogg

Then enable and start the script:

systemctl --user enable printy


systemctl --user start printy


If you do the above, whenever you need to print anything from Firefox, use ”Print to file” and place the PDF in /tmp/printy (if you use my script above).

”Wrong” vim color scheme for root

On (what I’ve noticed so far) Ubuntu based distros, one thing that bugged me was that on a fresh install when you sudo into root and edit for example a config file, all comments were in dark blue color (which on a terminal with black background is terrible) but when doing it as a normal user the color theme was more pleasing (readable).

This is how I ”fix” this.

First, add these two lines to /etc/profile (which is read by /bin/bash /bin/dash /bin/sh etc at login)

sudo echo 'export COLORFGBG="15;0"' >> /etc/profile

Then, add this line in your /etc/sudoers file to keep the setting.

Defaults        env_keep += "COLORFGBG"

Which makes sudo remember the COLORFGBG setting. You can add other stuff here as well, for instance maybe you want’t to be able to run stuff that only you have in your PATH with sudo.

Now when you login, and sudo edit a file you get bright colors. Yay! But wait, It don’t work you say? Well, I’m guessing you run KDE or some other fancy DE and it’s terminal. Most terminals for X do run bash, but they don’t run it as a login shell, so they don’t source /etc/profile and hence the settings above won’t do any good.

My solution is to add ”-l” to the command line starting bash, which makes bash behave as it’s running as a login shell.

Here’s how to do it in Konsole in KDE:

konsole_settings konsole_shell