Disable middle mouse button (paste) on Debian KDE

Every now and again I will accidentally click the middle mouse button when I go to grab my mouse, and KDE will dump my clipboard buffer into a BASH shell. Not good. Could run something damaging if I’m unlucky. So see here for the solution. Basically run this to get the mouse device ID:

xinput list | grep 'id='

Then to edit e.g. device 10 to disable middle mouse button:

xinput set-button-map 10 1 0 3

To persist the changes add the set-button-map command to e.g. ~/.xstartup.

Or you can add a pointer configuration to ~/.Xmodmap like this:

pointer = 1 0 3 4 5 6 7 8 9 10

And make sure xmodmap is applied at start-up with an autostart file like e.g. ~/.config/autostart/mouse-config.desktop:

[Desktop Entry]
Type=Application
Name=mouse-config
Comment=Disables middle mouse button.
Exec=xmodmap /home/jj5/.Xmodmap

Disabling F6 ‘Run Main Project’ hot key in NetBeans because of G15 keyboard

I have a G15 keyboard, and I love it (but not as much as the old model!), but it occasionally causes a problem for me when I’m programming in NetBeans on Debian GNU/Linux.

The issue is that on a newer G15 the G6 key is right near the Ctrl key, and from time to time my pinky hits the G6 key which seems to be by default programmed to be the F6 key.

By default in NetBeans the F6 key is the ‘Run Main Project’ hot key, so when I accidentally press it, it fires up a Firefox window and tries to run my web app! I never configure my web apps in NetBeans, but even if I did, I don’t want to accidentally run anything due to an accidental key press.

So my solution was to disable F6 in NetBeans, and for that:

Tools -> Options -> Keymap -> Click ‘Search in Shortcuts’ -> Press F6 -> Click on the ‘…’ in the Shortcut cell for ‘Run Main Project’ (should be F6) -> Clear -> Apply -> And you’re done!

Everything is easy when you know how!

Adding ‘Attach to Icedove’ desktop/dolphin menu item on Debian Jessie

On Debian Jessie (testing) the default ‘Send as Email Attachment’ context menu item uses KMail, and only KMail, even if you’ve configured your desktop to use Icedove (Thunderbird) as your default mail client.

So you can remove the broken ‘Send as Email Attachment’ from Dolphin by opening Dolphin then:

Settings -> Configure Dolphin… -> Services -> uncheck ‘Send as Email Attachment’

Then to create a replacement feature that uses Icedove edit:

~/.kde/share/kd4/share/icedove_attachment.desktop

And enter:

[Desktop Entry]
Type=Service
Actions=attachToEmail
Encoding=UTF-8
ServiceTypes=KonqPopupMenu/Plugin,all/allfiles
ExcludeServiceTypes=application/x-iso,kdedevice/*,inode/directory

[Desktop Action attachToEmail]
Exec=icedove -compose "attachment='$(echo %F | sed 's/\\ \\//,\\/\\//g')'"

Name=Attach to Icedove
Name[it]=Invia E-mail con Icedove
Name[es]=Enviar adjunto con Icedove
Name[de]=Als Anhang mit Icedove verschicken
Name[pt]=Anexar ao Icedove E-mail
Name[pt_BR]=Enviar arquivo(s) como anexo(s)
Name[fr]=Envoyer avec Icedove
Name[nl]=Voeg toe als bijlage aan Icedove
Name[pl]=Wyślij jako załącznik Icedove
Name[ru]=Отправить с помощью Icedove
Name[cz]=Odeslat jako přílohu Icedove

Icon=/usr/lib/icedove/chrome/icons/default/default16.png

And make sure your .desktop file is executable:

 $ chmod +x ~/.kde/share/kd4/share/icedove_attachment.desktop

Mounting Windows SMB share from Debian Wheezy

Configuring an SMB mount from my Linux box to my Windows box. This was helpful.

Basically:

# apt-get install cifs-utils

Then create your credentials file:

# cat > /root/amanda.smbpass  <<EOF
username=jj5
password=SECRET
EOF

Then edit /etc/fstab and add:

//amanda.jj5.net/Users  /media/amanda cifs defaults,noauto,credentials=/root/amanda.smbpass 0 2

Then create /etc/network/if-up.d/mount-amanda like this:

#!/bin/bash
mount /media/amanda

And make sure it’s executable:

# chmod +x /etc/network/if-up.d/mount-amanda

Mounting can also be done from the command-line:

# mount -t cifs -o username=jj5,password=SECRET //amanda.jj5.net/Users /media/amanda

Debugging PHPUnit tests in Eclipse PDT with XDebug on Debian GNU/Linux

Wow, this was complicated!

Make sure PHP, Xdebug, etc. are installed:

 # apt-get install php php5-xdebug php5-curl php5-mysql php5-gd

Install Eclipse:

 # apt-get install eclipse

To install PHP Developer Tools in Eclipse: Open Eclipse, click Help -> Install New Software…

Work with: http://download.eclipse.org/tools/pdt/updates/release

Select PHP Development Tools / PHP Development Tools (PDT) and install.

Create a new PHP project in Eclipse.

Download PHPUnit into your project folder, e.g.:

 $ cd ~/workspace/new-project
 $ wget https://phar.phpunit.de/phpunit.phar
 $ chmod +x phpunit.phar
 $ cp phpunit.phar /usr/local/bin/phpunit

In your Eclipse PHP project right-click on your project and select “Include Path” -> “Configure Include Path”.

Click “Libraries” -> “Add External PHARs” then add “phpunit.phar” (in your project’s workspace).

In Eclipse click “Run” -> “Debug Configurations”. Click “PHP CLI Application” and then “New”. Enter the PHP Script name as “PHPUnit” with Project default PHP: PHP CLI (Xdebug 5.4.4 CLI). Set the PHP file as “/project-name/phpunit.phar”.

Edit your php.ini file, e.g.:

 # vim /etc/php5/cli/php.ini

And make sure to specify an xdebug configuration (append to end of file is OK):

[xdebug]
zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_enable=On
;xdebug.remote_host="localhost"
xdebug.remote_host=localhost
;xdebug.remote_port=9999
;xdebug.remote_port=9000
xdebug.remote_port=9999
xdebug.remote_handler="dbgp"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/var/tmp"

xdebug.default_enable = on

xdebug.remote_autostart=on
xdebug.remote_mode = "req"
xdebug.remote_connect_back = on
xdebug.remove_log = /tmp/xdebug.log

Make sure you have a phpunit.xml file next to phpunit.phar in your workspace, e.g.:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
  backupStaticAttributes="false"
  syntaxCheck="false">
  <testsuites>
    <testsuite name="Tests">
       <directory suffix="Test.php">test</directory>
    </testsuite>
  </testsuites>
</phpunit>

Make sure there is one test in your test directory, e.g. /project-name/test/MyTest.php

<?php
class MyTest extends PHPUnit_Framework_TestCase {

  public function setUp() {
    //require_once( __DIR__ . '/../src/example.php' );
  }

  public function testExample() {
    $this->assertSame( '1', '1' );
  }
}

Double-click in the sidebar next to $this->assertSame to put a breakpoint there.

Then in Eclipse on the toolbar at the top is a little ‘bug’ icon, click ‘down’ next to that and debug ‘PHPUnit’.

Your unit tests should run in PHPUnit and break into the PHP debugger in Eclipse.

Did that work for you? Let me know!

Disabling sound in Debian KDE

I’m having a problem whereby my KDE session is “locking up” periodically for 5 or 10 minutes at a time. I checked /var/log/syslog and dmesg and it *seems* as though the high-priority audio threads are staving other threads, so I figure I’ll try to disable sound and see if my system continues to lock up. To disable sound I used:

root@mercy:/home/jj5# alsa force-unload
Unloading ALSA sound driver modules: snd-ens1371 snd-ac97-codec snd-seq-midi snd-seq-midi-event snd-rawmidi snd-pcm snd-page-alloc snd-seq snd-seq-device snd-timer (failed: modules still loaded: snd-ens1371 snd-ac97-codec snd-rawmidi snd-pcm snd-page-alloc snd-seq-device snd-timer).