Wednesday, 28 September 2011

Ubuntu 10.04 Lucid - notify-send in crontab not working

Alternative title: How to harness Ubuntu's black notification bubbles to set yourself repeating reminders

I recently found the wonderful command notify-send, which you can use to create those black Ubuntu notifications in the top right of the screen e.g. notify-send "Message Title" "This is my message." (you may need to install libnotify-bin). I then tried to shove this in my crontab to remind me to do stuff (e.g. take a short break every hour) but it didn't work.

Turns out that from the crontab, you have to tell it which DISPLAY to use, and luckily this turned out to be quite simply. All you need to do is add this prefix: DISPLAY=:0.0. So my crontab now looks like this:
# m h dom mon dow command
0 * * * * DISPLAY=:0.0 notify-send "Have a break" "Have a Kit Kat"

Thursday, 8 September 2011

Ubuntu 10.04 Lucid - Keyboard Shortcut to move window to other monitor (output)

I have a dual-monitor setup, and have always wanted to be able to move a window to another screen using a keyboard shortcut / hotkey. Turns out it is really easy:

CCSM (Compiz Comfig Settings Manager) > Put > Put to next output

I set it to <Ctrl><Alt>Enter

Saturday, 3 September 2011

jQuery slideDown() doesn't work on elements with CSS min-height

jQuery v1.6.2

I have an empty div with min-height defined in the CSS. When I use jQuery's slideDown() on it, it doesn't work - the div just instantly appears. Here is the workaround:

var myMinHeight = myElement.css("minHeight");
myElement.css({minHeight: 0}).animate({height: myMinHeight}, "fast", function() {
   $(this).css({minHeight: "", height: ""});
});

First we grab the CSS min-height value. Then we overide it, setting it to 0, and animate our div to the given min-height. At this point, we have what we want, but our CSS is messed up (e.g. say our CSS min-height was originally 120px, now our div will have a fixed height of 120px). This means if we add more content to the div, it cannot grow like we want it to (the very reason we were using min-height in the first place). The solution is simply to reset jQuery's inline style values (see line 3), after which it seamlessly reverts to your original CSS values.


REFERENCES
http://docs.jquery.com/Tutorials:Getting_Around_The_Minimum_Height_Glitch
http://jsfiddle.net/jitter/mLHb9/1/