Posts about iphone

Lock and unlock Ubuntu using your iPhone

18 January 2016
If, like me, you suffer from lazius extremis (lazy bastard, for the layman), you probably hate having to lock your computer when you leave and entering a password when you come back.

Fear not, young padawan, UDEV and xdotool to the rescue!

Here's how it works: UDEV (a linux mechanism that detects device events (including USB)) can be configured with rules that fire whenever something changes (i.e. a device is connected or disconnect from the system). When that happens, you want to run a script to lock or unlock your system, based on the type of rule that was fired. So, let's get started:

1. Create the UDEV rules:
1.1. Create a new file at /etc/udev/rules.d/100-lock-unlock-with-iphone.rules, with the following contents:

SUBSYSTEM=="usb", ENV{PRODUCT}=="2bc/12c8/520", ENV{DEVTYPE}=="usb_device", ACTION=="add",    RUN+="/home/youruser/bin/unlock"
SUBSYSTEM=="usb", ENV{PRODUCT}=="2bc/12c8/520", ENV{DEVTYPE}=="usb_device", ACTION=="remove", RUN+="/home/youruser/bin/lock"

1.2. In those lines, replace 2bc/12c8/520 with your device product id, which you can find running the following command in the terminal:

udevadm monitor --environment -u | grep PRODUCT

1.3. Disconnect or connect your iphone and you should see something like this:


1.4. That's the value you put in the rules.
1.5. Replace youruser with your own user name, by the way.

2. Which leaves us with the /home/youruser/bin/lock and unlock scripts to create. Here is the lock script:

export XAUTHORITY=/home/youruser/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=`ps -u youruser e | grep -Eo 'dbus-daemon.*address=unix:abstract=/tmp/dbus-[A-Za-z0-9]{10}' | tail -c35`
echo `date` "-" `whoami` "- Locking system..." >> $log
su youruser -c "DISPLAY=:0 gnome-screensaver-command -a"
echo `date` "-" `whoami` "- System locked!" >> $log

2.1. Again, replace youruser with your own.
2.2. You might be wondering what those lines about DBUS and the X server are all about. The reason for those is that UDEV runs stuff as root. And we want to lock and unlock the screen as our own user. Those lines make sure of that.
2.3. For the unlock script we need to install a tool called xdotool. It's basically an automation command that allows you to make the computer type stuff and control the mouse automatically. The reason to use this is because there is no way in hell you can unlock a locked screensaver (believe me, i've tried). This tool simulates user input (moves the mouse a little bit and the enters your password and presses enter). I know it's not the most secure thing in the world but it's the only way i could make it work. Install it with:

sudo apt-get install xdotool

2.4. Here's the unlock script:

 export XAUTHORITY=/home/youruser/.Xauthority
 export DBUS_SESSION_BUS_ADDRESS=`ps -u youruser e | grep -Eo 'dbus-daemon.*address=unix:abstract=/tmp/dbus-[A-Za-z0-9]{10}' | tail -c35`
 echo `date` "-" `whoami` "- Unlocking system..." >> $log
 export DISPLAY=:0
 xdotool mousemove 0 0 && xdotool type yourpassword && xdotool key Return
 echo `date` "-" `whoami` "- System unlocked!" >> $log

2.5. Replace youruser with your own user and yourpassword with your user password.

3. Reload the UDEV rules with:

sudo udevadm control --reload-rules

4. And now when you disconnect your phone from the computer, it should lock it. When you plug it back in it should unlock.

5. Happy hacking!

'You should get Training Time for iOS'

24 January 2015

And why, you might ask? For one because i made it :)

But seriously, if you are into intense, repetition-based training, you might want to take a look at it. It's an [iOS app](!/id692787267?mt=8) that allows you to set the duration of each repetition, as well as the resting time between reps. Then all you have to do is hit start and listen to the app as it tells you when to rest and when to exercise.

Because i rarely develop something i don't want for myself, i've been using it for a while, along with a set of 5-6 different exercices, for a total of 7-8 minutes of training everyday and i've found it to be a nice and fast way to be in good general shape. Your mileage may vary but you can always top that with, who knows, a bit of [Kung Fu]( ;)

Training Time! can be found on the App Store, [here](!/id692787267?mt=8).

Apple iPhone event 2012 in bullet points

24 January 2015

Running the risk of spoiling some things, i think i'll start with some of my favorite quotes from the live event :) Gizmodo on Jony Ive's video: "It's like saying you've been completely redesigned when you come back to eight grade two inches taller." "He's talking about the phone has been "completely redesigned," which is a very loose definition of either "completely" or "redesigned"." Engadget on the earpods: "Showing the old earbuds now, over 600 million have been shipped already to ruin 1200 million ears." Gizmodo on Siri: "I'm looking forward to the 2024 iPhone event when Siri's finally sentient." - And now the juice...

iPhone 5

Official name

Entirely in glass and aluminum (looks like the leaks)

Thinnest phone apple has made (7.6mm) 18% thinner than 4S

Weighs 112 grams 1/5 lighter

Retina display 326 PPI

4 inch display 1136x640 (16:9 aspect ratio)

1 more row of icons on start screen

Letter boxing for old apps

44% more color saturation. Full SRGB color spec

Integrated touch sensors into the display (thinner more glare-resistant)

LTE (4G) support

Voice and data on same chip (less space)

Automatic antenna switch, better signal

WIFI 802.11a/b/g/n 2.4GHz, dual channel 5GHz. (Ultrafast wireless - up to 150Mbps)

A6 chip (2x faster CPU, 2x faster graphics, 22% smaller)

8 hours 3G talk time / 225 hours standby / 10 hours wifi / 8 hours LTE browsing

8MP sensor camera

Dynamic low light mode

40% faster photo capture

Panorama photos (28MP images)

"Hit a button, swipe your phone around, boom giant picture."

1080p HD video. Video stabilization. 10 face detection.

720p front camera. Video stab. face detection.

FaceTime over cell networks

3 microphones (front, bottom, back)

Noise canceling earpiece

All the components getting smaller to make room for what needs to be bigger (battery)

Smaller connector cable called lightning (80% smaller, reversible - space reasons - only charges)

Some speaker brands working on lightning compatible devices

30pin to lightning adapter exists

Black and white versions


$199 for 16GB/$299 32GB/$399 64GB.

$99 16GB iPhone 4S

Preorder Sept 14

Shipping Sept 21. US Canada UK, France, Germany, Australia.

One week later to more countries. Fastest phone rollout ever. (sep 28 - Portugal included)

Free upgrade to iOS 6 on Sept 19

iOS 6

Share photo streams (likes/comments from friends)

New maps app

100 million POIs

New info card for restaurants

Turn by turn nav (wait for reviews)

No walking or subway directions yet

Satellite 3d imagery

Cinematic camera angles fly you around

Notification center improvements

Safari fullscreen mode

iCloud tabs (recover any tab you have open on ANY device)

VIPs in mail (special box)

Dynamic mailboxes for flagged messages

Passbook (airline boarding passes, movie tickets, coupons, etc) - shreds cards already used

Lock screen shows pass when you get to venue to use it

-Photos you take and share popup on your friends' iPhones (likes and comments possible)

Siri improvements

Facebook integration in siri (post to wall)

Overall more than 200 new features

iPhone 3GS will run iOS 6


New iTunes store on the iPad

Facebook "like" on all product pages

Completely redesigned (improved performance)

Preview while browsing (songs)

Better search results

Cleaner interface, no sidebar

iCloud builtin

iTunes store: concerts for artists

Available in "late October," so after iOS 6

ipod nano (7th gen)

More like the older, longer nano

Very small, longer screen

Aluminum body, plastic front

5.4mm thick (1/3 thinner)

Looks like a mini iPod touch

Lightning connector

2.5 inch multitouch display

Physical controls on the side

FM tuner (with live pause)

no iOS

Widescreen video

Fitness and pedometer built in

7 colors

Stream audio from the nano


iPod Nano is $149

Available in October

iPod touch (5th gen)

6.1mm thick (thinnest iPod touch ever)

88 grams

4 inch retina display

Widescreen video

Lightning connector

A5 chip (dual core cpu for iPod touch for the 1st time)

2x faster cpu and 7x faster graphics than previous gen

40 hours of music playback

8 hours of video playback

iSight camera (5MP)

Same five element lens as iPhone 5 (and sapphire crystal)

Panorama feature

Shared photo streams (iCloud)

iPhoto available for the touch as well

720p HD FaceTime camera. Back illumination.

Wrist strap (seriously?)

1080p HD video recording with stabilization and face detection

iOS 6

Siri on the touch

802.11 a/b/g/n Wi-Fi bump

Airplay mirroring

5 colors … with matching wristband :)

4Gen iPod Touch still exists - $199 for 16GB, 32GB for $249.

New touch $299 32GB and 64GB for $399

Available in October

ipod Shuffle

7 new colors


iPod shuffle: $50

Available in October

New headphones : Earpods

3 years in design

Controls bigger and easier to use

Exactly like what was leaked a couple of weeks ago

Shaped like your ear, but does not seal it

Will be standard with Touch, Nano, and iPhone 5

Available today

And there you have it. Basically specs bumps and not a lot more. I fail to see, this time, why this warranted the spectacle of an Apple event. Maybe Apple is becoming just another company, which is a shame.

Displaying all 3 posts