Archive for January, 2013
f.lux Makes For Sweet Dreams
by admin on Jan.26, 2013, under Linux
Last year a Hackerspace colleague turned me on to this nifty tool. (Thanks Andy!) It’s just the kind of thing I like: A super-simple, lightweight, “just works” applet that does something exceedingly useful – it red shifts your monitor as you enter evening.
http://stereopsis.com/flux/
It makes the color of your computer’s display adapt to the time of day, warm at night and like sunlight during the day.
It’s even possible that you’re staying up too late because of your computer. You could use f.lux because it makes you sleep better, or you could just use it just because it makes your computer look better.
Now, that that might sound boring or “not very useful” – but I encourage you to test drive it. True, you can manually adjust your monitor, have different color profiles, etc. but the beauty of this is it will color shift automatically – which is exactly what I needed.
I can’t tell you how nice it isĀ as I’m coding away at night (when I probably shouldn’t be) to have the screen dim to a nice rose tint. I swear I breath a sigh of relief every time. (And it even works with X when I’m playing a game, Diablo 3 looks pretty cool when it happens.)
In the morning, it is equally nice. Rather than be blinded when I turn on the monitor, it is far more soothing and acceptable.
It might indeed even help you sleep better by reducingĀ stimulation received from blue wavelength light during evening. Check out the research links at the site for further reading.
You can simply download the binary and run it:
wget http://secure.herf.org/flux/xflux.tgz
By providing your zip code (United States only) or lat+long it will be better able to time the transitions. Gnome / Ubuntu users can have a little control panel too – though it does not seem to play well with Unity. No matter though, you don’t really need it. You can add a symlink to the binary from your Desktop Environments startup folder, or be fancy and make a script that starts it every time you boot. A bash script follows which checks for a previously started instance. Sweet dreams.
#!/bin/bash
#!/bin/bash
# Script to automatically start xflux
# http://stereopsis.com/flux/
# wget http://secure.herf.org/flux/xflux.tgz
# To have it start automatically on user login:
# KDE: Place binary or this script in /home/$USER/.kde4/Autostart
# Gnome / Ubuntu: Run gnome-session-properties in terminal and add xflux (or this script) to the startup program list
# See: http://askubuntu.com/questions/48321/how-to-start-applications-at-startup-automatically
# Other: Create a symlink to the binary, or place it in your environments startup folder, etc.
# Usage: /usr/local/bin/xflux [-z zipcode | -l latitude] [-g longitude] [-k colortemp (default 3400)] [-nofork]
# protip: Say where you are (use -z or -l).
instance=`pidof xflux`
if [ -z $instance ]
then
/usr/local/bin/xflux -z yourZipCode
else
echo "xflux is already running with pid $instance."
echo "You may kill it with: kill $instance or pkill xflux"
fi
lslt Bash Function
by admin on Jan.26, 2013, under Linux
I’m always typing: ls -lhatr | tail
I decided this was getting old. ‘Alias’ was not going to really do what I wanted, so I made a little bash function instead, which can be put in your .bashrc, etc. Simple – but handy. And (of course) maintains colors.
The full script version :
#!/bin/bash
# List the last N items in specified directory in
# reverse time order (newest on bottom).
#
# Note however, the 'alias' commanad alone will not correctly handle args.
if [ $# -lt 1 ]
then
echo "Usage: $0 /foo N (optional)"
echo "Will perform ls -lhatr | tail -N"
exit 1
fi
dir=$1
echo "Listing $dir . . . "
ls -lhatr --color=always $dir | tail -$2
But you can achieve the same thing with a bash function, perhaps in your ~/.bashrc e.g.:
# lslt () { command ls -lhatr --color=always "$1" | tail -"$2"; }
#
# Or even fancier . . .
lslt () {
if [ $# -lt 1 ]
then
#type lslt //Works, but a nicer way is . . .
echo "Usage: lslt /foo N (optional)"
echo "Will perform ls -lhatr | tail -N"
else
command ls -lhatr --color=always "$1" | tail -"$2";
fi
}