How do I change the Timezone in Ubuntu?
Posted by Rhys in Uncategorized on 2011/04/22
This should save you some headache.
sudo dpkg-reconfigure tzdata
Stop the OpenOffice Recovery Anoyance
Posted by Rhys in Uncategorized on 2011/03/29
I don’t know why, but it doesn’t seem to matter on which computer, or which OS I’m running, OO.org always ends up prompting me for document recovery every time I open it, which I find particularly irritating. You can temporarily put an end to the madness by running the following in your terminal:
rm ~/.openoffice.org/3/user/registry/data/org/openoffice/Office/Recovery.xcu
This will only fix it until the next time it decides to mess with you, but hopefully that won’t happen for a while
Based on in_flu_ene’s post on Ubuntu Forums.
Detect Current Window Manager/Desktop Environment (e.g. Gnome/KDE/Xfce) from Bash Script
Posted by Rhys in Uncategorized on 2011/02/26
Want to have you script perform different functions based on the current window manager?
Personally, I want to start different applications based on what WM I’m running. So, I add my bash script to the auto-start applications, and let it figure out what to do. In my case, one of the things I want to do is run screenlets under Xfce (Xubuntu) but not under Gnome or KDE, amongst other things. Obviously you can use this to do anything you like.
Based on the fantastic information in this Ubuntu Forums post courtesy of Airr and Peyton, there are two approaches I particularly like.
The first is to use the $DESKTOP_SESSION environment variable. At this point, I couldn’t tell you what the possible values are, you’ll have to experiment with that for yourself.
The second method, is to check the currently running processes, for any of the following:
ksmserver(KDE)gnome-session(Gnome)xfce-mcs-manage(Xfce)
I’m sure you can also find other processes which are unique to your chosen desktop environment which a little experimenting.
Enjoy!
Ubuntu File Associations
Posted by Rhys in Uncategorized on 2011/02/17
For years now I have wondered to to setup/change “file associations”/default apps for file types in Ubuntu, but never really bothered to find out how. Well, I finally googled it, and found out just how easy it is, thanks to Kevin Guertin on Linux FUD.
Get Ubuntu Version Name
Posted by Rhys in Uncategorized on 2011/02/16
This is so easy!
Simply run…
lsb_release -cs
… and you’ll get back the codename of your ubuntu release, e.g. “maverick”, “natty”, etc.
Transmission is already running in Ubuntu
Posted by Rhys in Uncategorized on 2011/02/16
If you get the error message "Transmission could not be started" – "transmission is already running, but is not responding…" when you try to start Transmission, but you are sure that you killed all the processes already…. rather than reboot, simply delete the lock file with…
rm ~/.config/transmission/lock
… and try launching the application again!
Ubuntu: Pop-up notifications from shell scripts
Posted by Rhys in Uncategorized on 2010/09/21
I just stumbled across this handy little trick over at StealthCopter.com.
notify-send -t 5000 "Title" "Hello, world!"
Pops up with one of those nice little notification boxes.
You can even add an image to the notification…
notify-send -i ~/Pictures/my_photo.png -t 5000 "Title" "Hello, world!"
Generate Random Chars with Bash Script
Posted by Rhys in Uncategorized on 2010/06/14
An easy way to generate random characters from a bash script is create a variable holding a list of possible characters you would like to select from, then randomly select one of those characters from the list, as follows:
CHARLIST="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
let "POS=$RANDOM%${#CHARLIST}"
CHAR=${CHARLIST:POS:1}
I’ve created a simple script which fills your terminal with random alpha-numeric characters. It’s quite fun to watch ![]()
Download the script here, or execute the following in your terminal:
wget http://dl.dropbox.com/u/6900080/randchargen.sh; chmod +x ./randchargen.sh; export COLUMNS; ./randchargen.sh
Note: If you don’t export $COLUMNS before running the script, it will assume you have a width of 80 chars.
Safely Generate Passwords on Paper
Posted by Rhys in Uncategorized on 2010/06/13
After reading this excellent article by Andres Torrubia on generating unique passwords/writing them down on paper in a secure manner, I created some spreadsheets to help with your password generation.
Get the Google Docs Spreadsheet or the OOo Calc Speadsheet.
The spreadsheets both use this formula, if you were wondering:
=LEFT(RIGHT($B$3,INT(RAND()*LEN($B$3))),1)
In this case the cell “B3″ contains a list of all the possible characters to be used (e.g. 1234567890abcd…). To get more characters per cell, simply repeat the formula and concatenate with an ampersand.
Get Distro Name/Version in Bash Script
Posted by Rhys in Uncategorized on 2010/05/30
Thanks to reharpernc on the forums at unix.com.
The info you want is stored in /etc/*-release, and on my computer, looks like this…
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS"
You can easily use this info by placing it into variables in your script like so…
DISTRIB_ID=`cat /etc/*-release | grep DISTRIB_ID | cut -d= -f2`
DISTRIB_RELEASE=`cat /etc/*-release | grep DISTRIB_RELEASE | cut -d= -f2`
DISTRIB_CODENAME=`cat /etc/*-release | grep DISTRIB_CODENAME | cut -d= -f2`
DISTRIB_DESCRIPTION=`cat /etc/*-release | grep DISTRIB_DESCRIPTION | cut -d= -f2`

