Showing posts with label hacking. Show all posts
Showing posts with label hacking. Show all posts

Wednesday, October 31, 2007

Gutsy laptop lid tweak

I had a naggling little issue with gutsy on my laptop lid where when I closed the lid with it plugged in, the screen would turn off for a second, and then turn back on (I don't have the problem when not plugged in because I have it set to suspend when closed on battery power, which works beautifully). Thanks to the tweakfulness of linux, I was able to fix it in the following manner:

I created a file /etc/acpi/lidscreenblank.sh containing the following code:
#!/bin/bash

. /etc/default/acpi-support
. /usr/share/acpi-support/power-funcs

grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
getXuser;
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
. /usr/share/acpi-support/screenblank
fi
done
fi

then I made that file executable.
edited /etc/acpi/events/lidbtn

and changed
action=/etc/acpi/lid.sh

to
action=/etc/acpi/lidscreenblank.sh


then restarted acpi: sudo /etc/init.d/acpid restart

and voila! it works. I know its missing some of the screensaver handling that lid.sh was doing, but I dont really use screensavers anyways, so i guess i dont cante about that.

Monday, October 8, 2007

CUPS "hacking"

Just have a little trick I made up I thought I'd share.

I have an hp something-or-other printing that does both photos and paper. It installed nicely on the xubuntu box in our bedroom, but I have a mini running ubuntu with a nice big screen in the living room, and that's where we manage our photos. Its nice to have it in the living room because you can be all social and show off pictures and the like, but I got the mini and a flatpanel so I could keep the clutter in the living room to a minimum. So I have the photos in the living room and the printer in the bedroom.

So I was trying to share the printer using CUPS from xubuntu in the bedroom to ubuntu in the living room, but I was having a problem I wanted to be able to switch between using regular paper or photo paper from the living room, without going through the cups interface. (I like to make things nice and simple for my wife so she sees the advantage of linux over windows). As I was trying to get things set up I noticed that not all applications have the same printer interfaces. Some of them, like the gimp, have access to all the printer settings of the shared printer and you can choose the output from the print dialoge, but others don't have this built in, and even when it is built in, its a rather overwhelming dialoge. I wanted to be able to just pick print and hit go without having to worry about settings.

I did notice, however, that most of the print dialoges had a way to choose a default printer and that when I installed the printer in the bedroom, I was able to set default setting for it. So, while telling myself how smart I was, I added my printer twice to the server, once named "paper" with the paper tray as the default source, and once called "photo" with the photo tray as the default source. Then in my photo management application I set photo as the default printer and in openoffice, gedit, and firefox I set paper as the default printer. Now everything "just works". My wife can print documents, websites or photos without having to glance at any complicated printer dialoges.

Not that groundbreaking, I know, but hopefully someone will find it helpful.

Thursday, August 30, 2007

Seam Carving

Inspired by the following youtube video, I've been playing with implementing their seam carving in java. Its a pretty fun little problem. I've got it calculating importance and finding a path now, I just have to streamline it a little more so I can actually remove the path I find and find another one quickly, then I'll actually be able to resize images! Here's what I have so far (with a little help from this ):
And the inspiration:

Wednesday, July 11, 2007

gmail contacts updated

Ok, I updated the Gmail Contact List userscript, check it out at http://userscripts.org/scripts/show/10548

Saturday, July 7, 2007

Gmail Quick Contacts Greasemonkey script

I just hacked up a greasemonkey script to give a quick contact list when composing an email in gmail. A co-worker is trying to convert his grandfather to gmail, and his complaint was that he can't remember who he wants to mail, so he likes to peruse his contacts. Easy fix, just grabbed the All Contacts list with a GM_xmlhttpRequest, and Google already has them all nicely formatted for me.

Just click a contact to add it to the To: box


I think google already does this for their Google Apps gmail, but now you can have it too! If i can figure out how to get a userscript up here, that is.

edit: uploaded here: http://userscripts.org/scripts/show/10548