Archive for the 'Uncategorized' Category

Inhibit

Friday, September 16th, 2011

Two things I’ve been inhibiting this week: Arms traders – this I feel is pretty much self explanatory from an ethical and moral point of view.

…and slightly less on the world scale.. gnome power manager, which in gnome 2 there used to be an inhibit panel applet, but no such thing exists in gnome 3 as yet(?), so I quickly hacked this script up. It’s mostly useful for when watching flash videos etc.


#!/usr/bin/env python
from gi.repository import Gtk
import dbus

class Inhibitor:
def __init__(self):
mainWindow = Gtk.Window()
mainWindow.set_title ("Inhibitor")
mainWindow.set_default_size (50, 50)
mainWindow.set_resizable (False)
mainWindow.connect("destroy", self.on_mainWindow_destroy)

hintLabel = Gtk.Label ("Activate power saving inhibitor")
hintLabel.set_line_wrap (True)
hintLabel.set_width_chars (15)

inhibitSwitch = Gtk.Switch ()
inhibitSwitch.connect("notify::active", self.switch_activated_cb)

boxLayout = Gtk.VBox (spacing=5, homogeneous=False)
boxLayout.pack_start (hintLabel, False, False, 3)
boxLayout.pack_start (inhibitSwitch, False, False, 3)

mainWindow.add(boxLayout)
mainWindow.show_all()

bus = dbus.SessionBus()

proxy = bus.get_object ('org.gnome.SessionManager',
'/org/gnome/SessionManager')

self.sessionManager = dbus.Interface (proxy, 'org.gnome.SessionManager')
self.cookie = 0

def inhibit_gnome_screensaver (self, toggle):
if toggle == True:
self.cookie = self.sessionManager.Inhibit ("inhibtor 6000",
0,
"Manual override",
8)
else:
self.sessionManager.Uninhibit (self.cookie)

def on_mainWindow_destroy(self, widget):
Gtk.main_quit()

def switch_activated_cb (self, switch, pspec):
self.inhibit_gnome_screensaver (switch.get_active ())

if __name__ == "__main__":
Inhibitor()
Gtk.main()

Android development tools Linux quick ref

Thursday, July 28th, 2011

==== SDK (tools libs, emulator etc) ====

Download install SDK

http://developer.android.com/sdk/index.html

==== Run main tool ===

Start Android SDK and AVD Manager (Android Virtual Device)

android-sdk-linux_x86$ ./tools/android

=== Install SDK Platform  ====

android-sdk-linux_x86$ ./tools/android

Available packages -> Android Repository -> Select your target API version install

==== App: Creating =====

Usage:

android-sdk-linux_x86$ ./tools/android create project \
–target <target_ID> \
–name <your_project_name> \
–path path/to/your/project \
–activity <your_activity_name> \
–package <your_package_namespace>

Example:

android-sdk-linux_x86$ ./tools/android create project –target 1 –name SamsApp –path ~/dev/android/samsapp/ –package samsapp –activity Sam

==== App: Target an sdk version ===

This needs to be set otherwise the user will get asked asked for weird permisions.

In AndroidManifest.xml

<uses-sdk android:minSdkVersion=”8″ />

=== App: Target all screens ====

In AndroidManifest.xml

<supports-screens android:resizeable=”true”
android:anyDensity=”true” />

==== App: Data files ====

$cd /path/to/app
$mkdir ./assets

put stuff in ./assets

define is “android_asset” for that directory.

=== App: Source files ===

/path/to/app/src/<object>/BlaActivity.Java

=== App: Build  (debug build)===

$cd /path/to/app/
$ant debug

Example:

$cd ~/dev/android/samsapp/
$ant debug

packages arrive in /path/to/app/bin/

==== App: Install on emulator ====

Start the emulator.. ./android > Virtual devices > New/Start

$cd /path/to/app/

To Install:
$android-sdk-linux_x86/platform-tools/adb -s emulator-5554 install ./bin/theapp-debug.apk

To Reinstall:
$android-sdk-linux_x86/platform-tools/adb -s emulator-5554 install -r ./bin/theapp-debug.apk

== Get debug info from emulator ==

$android-sdk-linux_x86/platform-tools/adb logcat

===== App: Releasing =====

Generate a release key:

keytool -genkey -v -keystore my-release-key.keystore -alias keyone -keyalg RSA -keysize 2048 -validity 10000

In build.properties in /path/to/app/

“key.store=/path/to/your/android/my-release-key.keystore
key.alias=keyone”

$ant release

http://developer.android.com/guide/developing/index.html
http://developer.android.com/reference/packages.html
http://developer.android.com/guide/publishing/app-signing.html

Debian “Unable to mount filesystem”

Monday, June 6th, 2011

If you keep getting “Unable to mount filesystem” in Debian it might be because you installed debian via usb drive acting as a cdrom which may have put something like this in your /etc/fstab which makes it think that it should be a cdrom :

/dev/sdb1       /media/cdrom0   udf,iso9660 user,noauto     0       0

Meaning that every time you plug in a usb drive it’ll try and mount it as a cdrom:
dmesg:

[20772.399561] sdb: detected capacity change from 0 to 15997075456
[20772.402729]  sdb: sdb1
[20772.878756] UDF-fs: No anchor found
[20772.878762] UDF-fs: Rescanning with blocksize 2048
[20772.955887] UDF-fs: No anchor found
[20772.955891] UDF-fs: No partition found (1)
[20773.157277] ISOFS: Unable to identify CD-ROM format.

To be fair the image that I dd’ed on to a usb disk was a debian netinstall cd image (dd if=/path/to/image.iso of=/path/to/usbstickdev then cfdisk /path/to/usbdiskdev select make bootable) still a bit of a gotcha.

See also