Ormiret.com - Noteshttp://ormiret.com/?q=taxonomy/term/1/0
enNoteshttp://ormiret.com/?q=node/13
<p>These are notes that I keep for myself to remember how to do something when I come to do it again. If you spot any errors in here, or have a better way to do something: <a href="mailto:ormiret@ormiret.com">let me know</a>.</p>
NotesSat, 17 Feb 2007 09:38:00 -0500ormiret13 at http://ormiret.comGallerygenhttp://ormiret.com/?q=node/33
<p>I sat down to try and catch up with processing photos then got somewhat distracted and wrote a primitive static gallery generation system (thing). This might be why things take a long time to get off my TODO list. </p>
<p>gallerygen takes a CSV (like <a href="http://mte.bodaegl.com/static/berlin/list.csv">this one</a>) with filenames for the images that should make up each row in the gallery. It resizes the images as needed and builds an HTML page to display them. </p>
<p>I made an example gallery from my photos from <a href="http://mte.bodaegl.com/static/berlin/gallery.html">Berlin</a> last summer. </p>
<p>The code is <a href="https://github.com/ormiret/gallerygen">on github</a>. </p>
<p>There are a <a href="https://github.com/ormiret/gallerygen/blob/master/todo.org">few things to fix/improve</a>.</p>
NotesSun, 27 Jul 2014 20:17:57 -0400ormiret33 at http://ormiret.comGoogle filterhttp://ormiret.com/?q=node/28
<p>My method of naming things is to use a random word generator to come up with something I like the sound of. Some of the words it generates already exist though so I made a script to filter input to only the lines (which in my use case are words from the random word generator) that get no results from google. </p>
<p>The python script:</p>
<pre>
# Read lines from stdin and output those that get no results from google
import urllib
import simplejson
import sys
for word in sys.stdin.readlines():
query = urllib.urlencode({'q': word})
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;%s' % query
search_results = urllib.urlopen(url)
json = simplejson.loads(search_results.read())
results = json['responseData']['results']
if len(results) == 0:
print word
</pre><br />
NotesSat, 01 Jan 2011 21:07:40 -0500ormiret28 at http://ormiret.comSending simulated keyboard or mouse events to an X windowhttp://ormiret.com/?q=node/27
<p>Every so often I feel compelled to interact with a GUI app from the command line, either to automate something repetitive or because I want the control to come from something other than the mouse/keyboard actually connected to the computer running the app. I know there are ways to do this but I can never remember enough detail to find them quickly so I'm making a note here in the hopes I can find it quickly next time I decide that keyboard events need scripting.</p>
<p>The tool to do this is <a href="http://homepage3.nifty.com/tsato/xvkbd/">xvkbd</a> with something along the lines of:</p>
<pre>
xvkbd -text "[keys you want to send]"
</pre><p>
There are a few options for sending keys that aren't letters; the most generic is the <code>\[key_sym]</code> option. </p>
<p>xvkbd sends to whatever window has focus by default, for one off things it's easiest to stick in a delay and pick the window manually but for automated stuff the window will either need to be focused from the script or xvkbd told to send stuff to some other window.</p>
NotesThu, 24 Jun 2010 07:40:54 -0400ormiret27 at http://ormiret.comCalibration for touchscreen on X61 running Ubuntu 10.04 (Lucid Lynx)http://ormiret.com/?q=node/26
<p>First part of calibrating the touchscreen is getting the X and Y values the touchscreen is returning for the top left and bottom right of the screen. This is done by running</p>
<pre>xinput test 'Serial Wacom Tablet touch' </pre><p>
Then touching those two points of the screen and noting the output. <code>a[0]</code> is the x value and <code>a[1]</code> the y value. </p>
<p>For my screen the top left comes up as (48,86) and the bottom right as (931,946).</p>
<p>Next is to tell the wacom driver that this is where the screen is:</p>
<pre>
xsetwacom --set 'Serial Wacom Tablet touch' 'TopX' '48'
xsetwacom --set 'Serial Wacom Tablet touch' 'TopY' '86'
xsetwacom --set 'Serial Wacom Tablet touch' 'BottomX' '931'
xsetwacom --set 'Serial Wacom Tablet touch' 'BottomY' '946'
</pre><p>
If you have a system different to mine then the device you want to calibrate might not be called 'Serial Wacom Tablet touch' in which case substitute the name of your actual device wherever I used that. You can get a list of the devices from <code>xsetwacom</code>:</p>
<pre>xsetwacom --list </pre><p>
This works on Ubuntu 10.04 (Lucid), it might or might not work in other versions and distros. Things have been changing about how touchscreens are handled.</p>
NotesTue, 18 May 2010 08:07:22 -0400ormiret26 at http://ormiret.comSwitch off desktop icons in gnomehttp://ormiret.com/?q=node/24
<p>I've never liked having things on my desktop, so I want to tell nautilus not to put anything there. In true gnome fashion there doesn't seem to be any way to set such an option from the various dialogs that I thought to look in. There is an option though. Using gconf-editor you can set app/nautilus/preferences/show_desktop to false and the icons go away.</p>
NotesThu, 10 Jul 2008 12:30:25 -0400ormiret24 at http://ormiret.comMultiple monitors with xrandrhttp://ormiret.com/?q=node/23
<p>This way is a lot easier than the messing with xorg.conf I used to have to do for presentations and works well enough that I can add another monitor to my laptop whenever one is available (without even restarting X!). </p>
<p>I needed to make two change to the xorg.conf I got as default in Ubuntu Gutsy: change from the <code>i810</code> driver to the <code>intel</code> one, and add a line to increase the maximum size of the two displays. This makes the <code>Section "Screen"</code> look like:<br />
<!--break--></p>
<pre>
Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation Mobile 945GM/GMS/940GML Express Integrated Graphics Controller"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x800"
Virtual 2560 1824
EndSubSection
EndSection
</pre><p>
The <code>Virtual</code> line is the important bit. This isn't needed if you just want to mirror the internal screen to the external display, and the default for some drivers might be big enough without being changed.</p>
<p>Once that is done (and X has been restarted to pick it up) running <code>xrandr</code> will give a list of outputs and what modes it thinks will work with the devices attached to them. </p>
<p>I want to have the external display be a second monitor above the internal display and this is done by:</p>
<pre>xrandr --output VGA --mode 1280x1024</pre><p> to switch the output on and pick a resolution, then</p>
<pre>xrandr --output VGA --above LVDS</pre><p> to give it a position.</p>
NotesMon, 14 Jan 2008 08:36:48 -0500ormiret23 at http://ormiret.comMy Systemshttp://ormiret.com/?q=node/20
<p><b>Systems currently in use</b></p>
<p><!--break--></p>
<dl>
<dt>eblueer</dt>
<dd>A 13" Macbook Air. I like the hardware, I'm not really keen on OS X - but it runs a Debian VM that lets me mostly ignore OS X (Parallels even connects USB stuff through well enough to play with Arduinos and FPGAs from the VM). I'm getting over 14 hour battery life out of it, which really does make me a happy camper.</dd>
<dt>odruxeuo</dt>
<dd>A Toshiba Z830. My previous main system. Had taken a bit too much damage and got unreliable. Now sits on my desk to display stuff I like to glance at occasionally (IRC, email, video feed from ISS...).</dd>
<dt>bodaegl</dt>
<dd>A VPS from <a href="http://bitfolk.com/">BitFolk</a>. Running Debian, hosts a bunch of bazaar repositories and gets used for playing with stuff. Also provides offsite backups for important stuff and somewhere to tunnel to when I get stuck behind a restrictive firewall.</dd>
<dt>kolvigu2</dt>
<dd>My home router.</dd>
<p><b>Systems now retired:</b></p>
<dl>
<dt>eligeto</dt>
<dd>An Acer 2420. A nice laptop but not as nice and small as uxelecas which replaced it.</dd>
<dt>Ecramia</dt>
<dd>Nokia N810 internet tablet.</dd>
<dt>uxelecas</dt>
<dd>My previous main system. This is a Dell Latitude D420. Was handed off to my Granny.</dd>
<dt>farsink</dt>
<dd>A very old Dell desktop. This ran Debian and served as a server in my flat as it had no fans so could stay on all the time without annoying me. This machine no longer boots. It would probably be fixable if I ever get round to looking at what's wrong.</dd>
<dt>iglablua</dt>
<dd>Once upon a time this was my main laptop. This is a Lenovo ThinkPad X61 tablet running Ubuntu (though the last time I tried it wouldn't turn on).</dd>
<dt>ecruraze</dt>
<dd>My desktop in the office. It's getting a bit old now (original dual core vintage) but doesn't need to do anything too demanding anyway, it's fast enough to drive a couple of monitors and can usually keep up with my typing. Still set up but rarely used since I haven't been into the office in ages.</dd>
<dt>adrivorio</dt>
<dd>This is an HP tablet running windows XP. I used it when I needed to run windows software away from opradur, though not used much now as I've managed to get most of the windows stuff I use running in VMs on other machines.</dd>
<dt>opradur</dt>
<dd>Headless windows box for development that requires windows.</dd>
<dt>ossazoilio</dt>
<dd>An N900 phone/tablet thing. Saved me ever having to be without a computer, until the battery goes flat. Now in pieces waiting for me to replace a dodgy touchscreen.</dd>
</dl>
<p><b>Naming</b></p>
<p>I come up with names for new systems using <a href="http://sourceforge.net/projects/wordgen/">this</a> random word generator piped through a script to weed out anything that gets results from google until I find something I like the sound of.</p>
NotesFri, 07 Sep 2007 20:19:04 -0400ormiret20 at http://ormiret.comPower infohttp://ormiret.com/?q=node/19
<p>I've stopped using a panel, and the thing that I missed most about it was the info on the state of my laptops battery, so I wrote a script to display this information using <code>libnotify</code>:</p>
<pre>
#!/usr/bin/python
import pynotify, math
batt_info = open('/proc/acpi/battery/BAT0/info').readlines()
batt_state = open('/proc/acpi/battery/BAT0/state').readlines()
full = int(batt_info[2].split()[3])
low = int(batt_info[5].split()[3])
current = int(batt_state[4].split()[2])
rate = int(batt_state[3].split()[2])
state = batt_state[2].split()[2]
if state == "charging":
remaining = full - current
time = remaining/float(rate)
hours = int(math.floor(time))
mins = int(math.floor((time-hours)*60))
if pynotify.init("power-info"):
pynotify.Notification("Charging",
repr(hours)+":"+repr(mins).zfill(2)+" till fully charged.").show()
if state == "discharging":
remaining = current - low
time = remaining/float(rate)
hours = int(math.floor(time))
mins = int(math.floor((time-hours)*60))
if pynotify.init("power-info"):
pynotify.Notification("On battery",
repr(hours)+":"+repr(mins).zfill(2)+" remaining.").show()
if state == "charged":
if pynotify.init("power-info"):
pynotify.Notification("Fully Charged").show()
</pre><br />
NotesFri, 10 Aug 2007 21:47:27 -0400ormiret19 at http://ormiret.comBeryl emacs togglehttp://ormiret.com/?q=node/17
<p>I've hacked up a little script to toggle emacs. It is very hacked together and there are a load of things I can think of to fix/improve.</p>
<p>The most obvious would be replacing the <code>dbus-send</code> command with the python dbus support, but after a couple of hours of looking at messages telling me that methods didn't exist to match the patterns I was using to call them I gave up. The pipes to get the IDs should probably be implemented in python too...</p>
<pre>
#!/usr/bin/python
# Python script to use beryl to toggle display of emacs
import os
get_current_id = "xprop -root | grep _NET_ACTIVE_WINDOW\(WINDOW\) | awk '{ print $5 }'"
get_emacs_id = "xwininfo -root -children | grep emacs@ | awk '{ print $1 }'"
get_root_id = "xwininfo -root | grep id: | awk '{ print $4 }'"
current_id = int(os.popen(get_current_id).readlines()[0], 16)
try:
emacs_id = int(os.popen(get_emacs_id).readlines()[0], 16)
except IndexError:
# Emacs isn't running
os.spawnlp(os.P_NOWAIT, 'emacs', 'emacs')
exit
root_id = int(os.popen(get_root_id).readlines()[0], 16)
if current_id == emacs_id:
minimise = "dbus-send --type=method_call --dest=org.freedesktop.beryl " + \
"/org/freedesktop/beryl/core/allscreens/minimize_window " + \
"org.freedesktop.beryl.activate string:root int32:%i "%root_id + \
"string:window int32:%i"%emacs_id
os.popen(minimise)
else:
activate = "dbus-send --type=method_call --dest=org.freedesktop.beryl " + \
"/org/freedesktop/beryl/core/allscreens/activate_window " + \
"org.freedesktop.beryl.activate string:root int32:%i "%root_id + \
"string:window int32:%i"%emacs_id
os.popen(activate)
</pre><br />
NotesFri, 29 Jun 2007 22:31:29 -0400ormiret17 at http://ormiret.com