Some useful OSX hints

Edit: I just found this draft laying around. Forgot I wrote it.
The hints are solid so I am publishing them as is.


Make Terminal useful, as in more a Linux one.
http://www.twam.info/software/tune-terminal-in-os-x-lion

Combine Safari’s URL and Search Bars with Safari Omnibar
http://osxdaily.com/2011/08/05/safari-omnibar-combine-safari-url-and-search-bar/

Open Finder using a global shortcut

⌘-Option-Space bar

source and alternatives: http://forums.macrumors.com/showthread.php?t=422337

Fix the switch terminal windows shortcut on Swedish OSX Lion

I just found the way to switch focus between active terminal windows in OSX Lion on Swedish locale.
Why didn’t I find this when I searched for it every other time?

In Swedish:
Jag hittade nyss hur man växlar fokus mellan aktiva terminal-fönster i OSX Lion med Svenska språkinstaällningar.

I “Keyboard Preferences -> Shortcuts” så ändrar du (dubbelklick)
 “Move focus to the next window” till “cmd-<".

Detta sätter också automatiskt cmd-> eller cmd-shift-< till växla till föregående fönster. Standardinställningen för mig var innan “cmd-.” och det fungerade inte alls utan skickade istället en ^C till terminalen…

source: http://superuser.com/questions/299241/in-mac-os-what-is-the-keyboard-shortcut-to-switch-between-instances-of-the-samev

Stream audio using Airplay to Android Phone

While searching for a way to stream music from my Android phone to an Airplay server I found an Android app that does the opposite. 
I tried It and it really works. At least until the phone goes to sleep…

Stream audio using Airplay to Android phone with vavi-apps-shairport:
http://code.google.com/p/vavi-apps-shairport/
If anyone find out a way of doing the opposite please let me know.
That is tapping into the audio-system of the Android and sending all audio to an Airplay server. Like Airport Express or Apple TV or the shairport software that I use.

Restoring Backslash, Pipe and Curly Brackets to where it belong on Macbook with Swedish keyboard layout

I have managed to restore Backslash and Pipe to where they belong, on my Macbook Pro running Swedish keyboard layout.
Update: It also works fine on my Macbook Air
Update2: Karabiner is the new name of the product used here.
Update3: Karabiner-Elements is the next available product, but it is still lacking required features.
Update4: This sollution does not work anymore in OS X Sierra / 10.12.x. But I solved the same problem using a keyboard layout shipped with Ukelele. It’s called “Logitech – Swedish”. I might write a new post on that later on but basically you put the file in ~/Library/Keyboard Layouts/ and select it in keyboard preferences.

My interpretation of where they belong is as on standard PC (Windows/Linux) keyboard layout.

And I’m so happy about this so I feel the need to share my findings.

Essentially what it does is the following:
– Puts the | “Pipe” to the < “Less than” key with option/alt modifier.
– Puts the \ “Backslash” to the + “Plus” key with option/alt modifier.
– Restores the replaced mappings to be reached where those keys used to.
Update 130817:
– Added curly brackets { } 
– Added todo (please comment if you implement these)

I did this using KeyRemap4MacBook and custom remap settings.

Here is how:
Download and install KeyRemap4MacBook.
– Reboot (it uses some kernel extension…)
– Notice that you have a new icon in Finder statusbar.
There is a shortcut to preferences if you click it. A square key?
– Set up a new named layout profile under the MenuBar tab It is nice to have during tests, and to fallback on.
– Activate the new layout profile it from the statusbar icon
– Go to preferences again and -> Misc & Uninstall -> Open private.xml
– Open the private.xml in a texteditor of choice
– Replace the content it with the following text:

<!--?xml version="1.0"?-->
 
Fix PC-like Pipe and Backslash on Swedish keyboard
private.fix_pc_backslash_and_pipe_swe
<!-- PC-Like Backslash :: Move ± to \ position :: ALT-MINUS to OPTION+SHIFT-7 -->
__KeyToKey__ KeyCode::MINUS, VK_OPTION, KeyCode::KEY_7, VK_SHIFT | VK_OPTION
<!-- PC-Like Backslash :: Move \ to ± position :: OPTION+SHIFT-7 to ALT-MINUS -->
__KeyToKey__ KeyCode::KEY_7, VK_SHIFT | VK_OPTION, KeyCode::MINUS, VK_OPTION
<!-- PC-Like Pipe :: Move | to ≤ position :: ALT+LESS_THAN to OPTION-7 -->
__KeyToKey__ KeyCode::SWEDISH_LESS_THAN, VK_OPTION, KeyCode::KEY_7, VK_OPTION
<!-- PC-Like Curly Brackets :: Move | to { position :: OPTION_R-7 to SHIFT+OPTION_R-8 -->
__KeyToKey__ KeyCode::KEY_7, ModifierFlag::OPTION_R, KeyCode::KEY_8, ModifierFlag::OPTION_R | ModifierFlag::SHIFT_R
<!-- PC-Like Curly Brackets :: Move { to | position :: SHIFT+OPTION_R-8 to OPTION_R-7 -->
__KeyToKey__ KeyCode::KEY_8, ModifierFlag::OPTION_R | ModifierFlag::SHIFT_R, KeyCode::KEY_7, ModifierFlag::OPTION_R
<!-- PC-Like Curly Brackets :: Move ≈ to } position :: OPTION_R-0 to SHIFT+OPTION_R-9 -->
__KeyToKey__ KeyCode::KEY_0, ModifierFlag::OPTION_R, KeyCode::KEY_9, ModifierFlag::OPTION_R | ModifierFlag::SHIFT_R
<!-- PC-Like Curly Brackets :: Move } to ≈ position :: SHIFT+OPTION_R-9 to OPTION_R+0 -->
__KeyToKey__ KeyCode::KEY_9, ModifierFlag::OPTION_R | ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::OPTION_R
 
<!-- todo opt 1 ->
upsidedown !
opt 5 -> euro
opt 6 -> yen
shift paragraph -> 1/2 sign
convert to karabiner-elements config
submit config to karabiner official site
-->

– Now chose “Reload XML” in the preferences “Change key” tab.
– In the top a new option should appear: “Fix PC-like Pipe and Backslash…” (see name in private.xml)
– Click it.
– DONE! No need to save. Test it out.

If you need to customize yourself, refer to the documentation.

Some tips:

– set US keyboard in System preferences, switch to it using the flag-icon in statusbar, then use the Eventviewer to find the keys you are interested in remapping.
The keycodes are in hex and need to be translated into decimal before you can map them to the corresponding Keyname in keycode.data (see links below).
– Use the | char to allow multiple combination keys.
– Oddly the combination-keys go after the standard key, not before.

Introduction and documentation:
(scroll around, this page shows where the private.xml is found)
http://pqrs.org/macosx/keyremap4macbook/document.html#t3

Private.xml reference manual:
(at least check out this one if you want to fix something else)
https://pqrs.org/macosx/keyremap4macbook/xml.html.en

iPhone internet sharing with Ubuntu

Internet sharing using a mobile phone as network accesspoint, also known as tethering is a good thing. I’ve got it easily up and running on my HTC Desire (over wifi), my Nokia E71 (over adhoc-wifi) and now I’ve got it working on my gf’s iPhone. This post is about that.

Thank’s to this url I could easily get it up and running in a few steps summarized as follows:
– Be sure that your other network connections (ex Wifi) are disabled
– pair the devices (I used the ubuntu standard bluetooth icon in the panel). Setup new devices or whatever…
– follow the guide (paste the apt commands to add repository and install blueman)
– run command blueman-manager
– find the iPhone in the list, choose Network – connect, or setup and then choos network connection.
– You should get a success message or get some indication of that you are connected to the device and using “network…”.
– in a terminal run ifconfig
– you should se an interface named bnep0 probably
– get an ip from the iPhone by running the command: dhclient -i bnep0
You are now connected. At least I was =)
If not proceed with normal network troubleshooting using bnep0 as your external network interface.

I used Ubuntu 10.04.

The howto on the link above also describes how to tether Ubuntu and an iPhone over USB instead of bluetooth. That I haven’t tried… yet.

Good Luck!

Ubuntu Timemachine-server for Snow Leopard

I got Timemachine to work against my Ubuntu fileserver using this guide.
And here’s a swedish article that seems to apply.
That one also includes a script for making the sparse file.

I haven’t tried any restores yet as the initial full-backup is still in progress.
Maybe I’ll post an update about it.

Update: It stopped working. After some more research I’ve found that there’s some command 78 or other extra apple-features added to the “netatalk” protocol. Having something todo with reclaiming space within the sparse-file or something… Without these commands, the backup-image self-destructs. Some sort of patch exists, but I haven’t the time to pursue… Also some third party “Drobo add-on project” seems to have sorted out this problem. If the code is available someone should implement and test that on Ubuntu. And if you do find a sollution please leave me a note. 😉
– 100919

Update: I’m at it again, since I’ve found some articles that the issues should be fixed. It seems to work occasionally. I have setup my dhcp for mac address fixed IP:s and proper DNS records (maybe not needed, but useful). The afp “shares” or “disks” are only accessible by the macbook from it’s wireless or wired IP:s. It seems to work on and off, and I do full backups pretty often (like 2 every month at least) when Timemachine says the backup failed verification. I don’t know why this is happening. But my money is on either glitching automounting of netatalk afp:s or packets go missing when on wireless.
Next up is to remove the WIFI from the equation.

Restore dar easily in Ubuntu 10.04 LTS, or not?

Update 1: I got the dapper version of kdar to work. I never tried it because I didn’t think it would work. But the packages installed without any trouble and works just as good as in Ubuntu 9.10.

Update 2: I also tried pybackpack that is a nice gui
for manual backups using rdiff-backup. Rdiff-backup can do remote backup using ssh but needs rdiff-backup installed on both client and server. It’s somewhat similar to rsync in that aspect. Pybackpack I had to pull from the SVN repos, since the packages that exist had major bugs relating to gui-changes causing it to be broken. Pybackpack project site: http://projects.sucs.org/projects/pybackpack/

Update 3: Using archfs on my backupserver I can get the backup-images fuse-mounted and have direct file access to all previously backed file-versions. There are two views that one can mount using options. One show each file as a directory containg all versions of that file with a date+timestamp, and there is the default view that shows date+timestamps as directorys in the root of the mountpoint and below the directory structure as it where for that specific backup. Since my backup-server is a Debian Lenny I had to pull the archfs-package from the unstable repository (I changed the /etc/apt/sources.list to include an unstable-source during the install, and then removed it).

I never tried sbackup since it doesn’t match my needs.


Ok so it seems I might have been praised the use of dar alittle to soon in my previous post. Well at least the use of kdar as of now. I’m having trouble getting it to run on Ubuntu 10.04.

And all that my major research-crawling gives me is Dargui, (gnome/gtk gui) that also won’t work (yet) in Ubuntu 10.04 LTS.

And I also found a completely different approach: rdiff-backup with archfs.

I will probably end up extracting my dar-archive completely or zip it or something (i only want to archive this backup set of my old laptop-installation of 9.10). And then I will try archfs for incremental backups of my current setup.

I will post a follow up on this when I have it done.

And yeah, if you only want to backup a few files easily there should be an option in Ubuntu 10.04… I think it’s called sbackup. There also some backintime project and dejadup that I have to look into.

To be continued…

Backup Linux-system using DAR

You gotta love dar!

Do yourself a favour and hit a “apt-get install dar kdar; man dar”, and engulf yourself in it’s possibilities. Or just take a glipmse at the features here.
And if you are like me, and just want the job done, take a look at kdar (a gui).
I just finished a kdar-backup of my laptop, ran from a script created with kdar with some additions (removal of -p option and addition of –exclude-file option).
dar -v -c “/media/externaldrive/dar/d420.u910.root.100606” -R “/” -s 734003200 -D -y -m 150 -Z “*.avi” -Z “*.bz2” -Z “*.deb” -Z “*.gif” -Z “*.gz” -Z “*.iso” -Z “*.jpg” -Z “*.mov” -Z “*.mpg” -Z “*.pbm” -Z “*.pdf” -Z “*.png” -Z “*.pnm” -Z “*.Z” -Z “*.zip” -P “media/externaldrive/dar” -P “dev” -P “dev/pts” -P “dev/shm” -P “lib/init/rw” -P “media” -P “mnt” -P “proc” -P “sys” -P “tmp” -P “var/lock” -P “var/run” -P “var/tmp” –exclude-file=excludefiles
Pretty basic right? =)
And look at this beauty of summary generated when finished:

361049 inode(s) saved
with 421 hard link(s) recorded
0 inode(s) changed at the moment of the backup
0 inode(s) not saved (no inode/file change)
1 inode(s) failed to save (filesystem error)
10 inode(s) ignored (excluded by filters)
0 inode(s) recorded as deleted from reference backup
——————————————–
Total number of inodes considered: 361060
——————————————–
EA saved for 0 inode(s)
——————————————–

I’m planning to use a script like this one generating an excludefile to exclude all package-installed files:

#!/bin/bash
COLUMNS=185 dpkg -l|awk ‘/^ii/{ print $2 }’|xargs -l dpkg -L|sort -u > dpkg-files

LampKontroll v0.1 done!

It’s not pretty codewise, and it could use some ajax, but at least the iWebkit makes it look ok and it’s functional. And it works on both iPhone and ofcourse android and other browsers as well 🙂