måndag 22 april 2013

Automatically change keyboard settings

When using an external (Windows) keyboard with your Mac you probably want to modify your keyboard layout, for instance change Windows button to Option and Alt button to Command.

A nice program for this is KeyRemap4MacBook, but that is not what this article is about, since there is a lot of information about that program already on the web.

My issue is that I switch a lot between the laptop keyboard and the external keyboard, depending on if I sit by my desk or not. There is a nice thing i KeyRemap4MacBook to switch profiles. However I do not want to manually switch profiles every time I (dis-)connect my external keyboard.

So I created a bash script that detects if an external keyboard is connected and then I schedule this with crontab.

The script:

#!/bin/bash
externalConnected=`/usr/sbin/system_profiler SPUSBDataType|grep -i keyboard|grep -vi internal`
if [[ "" == "$externalConnected" ]]; then
newSetting=1
else
newSetting=0
fi
currentSetting=`/usr/libexec/PlistBuddy -c "Print :selectedIndex" ~/Library/Preferences/org.pqrs.KeyRemap4MacBook.plist`
if [[ $newSetting != $currentSetting ]]; then
/usr/libexec/PlistBuddy -c "Set :selectedIndex $newSetting" ~/Library/Preferences/org.pqrs.KeyRemap4MacBook.plist
killall KeyRemap4MacBook
fi

This assumes that you have two profiles in KeyRemap4MacBook and that the first one is the profile for the external keyboard!

Crontab:
* * * * * ~/Scripts/detect_external_keyboard.sh
* * * * * sleep 15; ~/Scripts/detect_external_keyboard.sh
* * * * * sleep 30; ~/Scripts/detect_external_keyboard.sh
* * * * * sleep 45; ~/Scripts/detect_external_keyboard.sh

As you see I had to add 4 rows to make it run more often than once per minute.

tisdag 26 februari 2013

CopyQ

Found this today, CopyQ, seems like a great clipboard manager. Let's see if it beats ClipIt.
URLs:
  • https://github.com/hluk/CopyQ#readme
  • http://www.webupd8.org/2013/02/copyq-interesting-clipboard-manager.html

torsdag 21 februari 2013

Ubuntu Phone

Tried Ubuntu Phone today on my Galaxy Nexus. Slick interface. Let's hope they get all functiality working eventually.

See more here: https://wiki.ubuntu.com/Touch



tisdag 19 februari 2013

Massive photo tagging

Use exiftool!

sudo apt-get install libimage-exiftool-perl
~/Pictures/2012> exiftool -keywords+=2012 -overwrite_original -q *


This will tag all photos under current folder, recursively, with the tag 2012.


måndag 11 februari 2013

Disable Unity Spread

The Spread function is lagging on my laptop and I have, for a long time, tried to find a way to disable it.

Now I have to search no more! Unity Tweak Tool to the rescue.



Open the program, then goto Window management -> Window spread -> Disable.

Spread is used when you click the app icon in the launcher and there are (at least) two available windows for that app.

Installation instructions on Lifehacker.

måndag 4 februari 2013

Faster photo viewer

Not sure why they use Gnome Image Viewer as the default image viewer in Ubuntu. I prefer gThumb, which is a lot faster.


Simply open up All Settings -> Details -> Default Applications and select your favorite image viewer there.

tisdag 29 januari 2013

Automatic mute when unplugged


  • Install pavucontrol 
  • Open PulseAudio Volume Control
  • Go to Output Devices
  • Choose Speakers under Port
  • Click the mute button
 Now notice how your computer automatically mutes if you unplug your headphones!

måndag 28 januari 2013

Sticky Edges

Seems that sticky edges cannot be configured under Display settings in 12.10.
Instead go to CCSM -> Unity -> Experimental and uncheck Capture Mouse.

http://askubuntu.com/a/123814/126739

Move window

Working with two monitors is very nice, and there is a nice feature in Compiz to quickly move current window to the other display.

To enable it:
  1. Install packages compiz-plugins compiz-config-settings-manager
  2. Open ccsm and enable plugin Put
  3. Go to the configuration for Put
  4. Set a keyboard shortcut for the function Put to next output 
  5. (Not always needed) Restart Unity by running setsid unity from a terminal

lördag 26 januari 2013

Migrate Picasa Database


I reinstalled my laptop with the latest version of Ubuntu.

I had to do some digging on how to migrate the Picasa database, a there was not much good information when googling.

The folders you need to keep are:
~/.google/picasa/3.0/drive_c/Documents and Settings/<user>/Local Settings/Application Data/Google/Picasa*
OR
~/.wine/drive_c/users/<user>/Local Settings/Application Data/Google/Picasa*

So:
  1. Install Picasa
    • Use default Wine (1.4)
    • Use the following commands: https://wiki.helsinki.fi/display/~pervila@helsinki.fi/Picasa+3.9+on+64-bit+Ubuntu+12.04
  2. Overwrite the above folders with your backed up folders

This works for both Picasa 3.8 and 3.9.


torsdag 3 januari 2013

Back to Firefox

Have been using Chrome for a while but before that I was a dedicated Firefox user. Not sure why I switched, but now I know why I am switching back to Firefox:
  • Ctrl+Tab - It is not possible to easily switch to the most recently used tab in Chrome. In Firefox the default behaviour is to switch to the next tab when pressing Ctrl+Tab, but by installing the extension Tab Mix Plus you can change this behaviour.
  • Keyboard shortcuts in Google Docs - Many are simply not working for me in Chrome. E.g. Ctrl+Shift+8 for bullet list.
  • Single window mode - Single window is nice since that makes the restore session more fail safe. Chrome for instance only remembers the last window closed when restoring session. Single window would not be sufficient if you couldn't tile browser windows, which will not work in single window mode in Chrome. But in Firefox there is a plugin for this: Tile Tabs.
One feature that is lacking in Firefox, though, is the ability to move tabs using keyboard shortcuts. E.g. move tab one step left using Ctrl+Shift+PageUp. This was however solved by installing the plugin Move Tabs.