Determine Host OS with Java

2010/05/26

Thanks to Bill on ObjectMix and Roedy Green on MindProd.

You simply call System.getProperty("os.name") and one of the following values will be returned…
AIX
Digital Unix
FreeBSD
HP UX
Irix
Linux
Mac OS
Mac OS X
MPE/iX
Netware 4.11
OS/2
Solaris
Windows 2000
Windows 7
Windows 95
Windows 98
Windows NT
Windows Vista
Windows XP

I presume there are other values on Java enabled phones, etc.

Convert ODT to PDF from the command line

2010/05/25

Thanks to scls19fr on the OOo Forum for this lovely tip.
You can convert OpenOffice Writer files to PDF from the command line using unoconv -f pdf input.odt
To get unoconv, simply run sudo apt-get install unoconv at the terminal.

“vitals” Bash Script – Check your computers vital stats in the terminal!

2010/05/25

[Download: vitals.sh]
Here’s a script I wrote to show all the vital info about my comp on the terminal. Output includes user name, host name, disk usage, battery status, cpu usage, ip address, etc. The output is even colorized for prettiness :)

Sample output:
USER: rhys
HOST: ubuntu
DATE: Tue May 25 16:39:07 EST 2010
IP ADDRESS: 192.168.0.5
CPU: Pentium(R) Dual-Core CPU T4400 @ 2.20GHz
Cpu(s): 9.6%us, 4.1%sy, 0.4%ni, 85.6%id, 0.2%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 3355256k total, 3154672k used, 200584k free, 499232k buffers
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1535 rhys 20 0 87448 51m 17m S 8 1.6 14:46.70 compiz
27066 rhys 20 0 346m 67m 27m S 8 2.1 18:22.36 chrome
27249 rhys 20 0 357m 58m 27m S 8 1.8 83:01.46 chrome
1140 root 20 0 78196 37m 15m S 6 1.2 49:27.51 Xorg
31340 rhys 20 0 77256 24m 14m S 6 0.8 0:06.47 /usr/bin/termin

DISK USAGE:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 911G 617G 295G 68% /host
/dev/sde1 932G 924G 7.6G 100% /media/The Terror 02

It will continue to update every second, until you press Ctrl + C, at which point it will clean up after itself, and exit. Remember to set the file to executable with chmod +x ./vitals.sh before you try to run it.

If you wish to also view your battery status, you must install the acpi package. To do this under Debian/Ubuntu, simply type sudo apt-get install acpi at the terminal.

Recommended usage:
I suggest you copy the script to your ~/bin directory if you have one, and rename the script to vitals (no .sh extension). This way you can simply type vitals at the terminal any time to quickly see your vital stats! For the lazy, simply copy and paste this into your termial:
[ ! -d ~/bin ] && mkdir ~/bin; wget http://dl.dropbox.com/u/6900080/vitals.sh; mv ./vitals.sh ~/bin/vitals; chmod 755 ~/bin/vitals; ~/.profile
This will create the ~/bin directory if it doesn’t already exist, download the latest version of the script, move it into your ~/bin directory, and set the appropriate permissions. Finally it will execute your ~/.profile script which hopefully will add ~/bin to your PATH.

Move window buttons in Lucid Lynx/Ubuntu 10.04 to right

2010/05/25

In an attempt to be annoying, the otherwise adorable Ubuntu development team decided to move the window buttons (minimize, maximize, close) to the left-hand side of the title bar in Ubuntu 10.04. They succeeded (in being annoying).

This is, however, fortunately particularly easy to remedy. All you need to do is pop open a terminal, or press Alt+F2 to open the Run Application dialog, and execute the following command:
gconftool --set /apps/metacity/general/button_layout --type=string ":minimize,maximize,close"

The change should take effect immediately. Happy computing!

How to stop touchpad tap-to-click in Xubuntu/Xfce

2010/05/25

Use Xubuntu/Xfce on your laptop, and keep bumping the touchpad only to trigger the “tap-to-click” function, and click the wrong thing/mess up your typing/launch a nuke inadvertently? So annoying that you went back to GNOME? I know I did! Fear not, it shall happen no longer, thanks to a tip from EricDP on the Ubuntu Forums.

Click Applications > Settings > Xfce 4 Settings Manager, then click the Sessions and Startup.
Now, select the Application Autostart tab, then press Add.
Enter a suitable name and description, then in the Command box enter: synclient MaxTapTime=0 and press OK.
That’s it. Now restart Xfce (log out, log back in), and tap-to-click on the touchpad should be disabled.

Note: When you log in, tap-to-click will still be active for several seconds until the command is executed by Xfce. If you know of a way to have it executed earlier and still have the desired effect, please let me know :)

Driving Skills

2010/01/31

How to handle a blowout while driving
How to drive on ice

Desktop

2009/08/28

Desktop

This is my current desktop and the elements that make it up.

Xfce

  • Xfce Menu
  • Places
  • Launchers x3
  • Spacer
  • Mixer
  • System Load Monitor
  • Screenshot Used for taking the screenshot ;)
  • Notification Area
  • Clock
  • Action Buttons Shutdown, Logout etc

Screenlets

Avant Window Navigator

  • Cairo Main Menu
  • Media Control

Google Gadgets

Enable USB Access to SD on G1 from Recovery Mode

2009/08/28

With Cyanogen’s recovery installed, go to the console and type “ums_enable”.
Thanks, Cyanogen

Updates

2009/08/23

I just finished copying across several of the more useful posts from my old blog to this one.

Adjust Terminal Resolution

2009/08/23

I wanted to find out how to change the resolution of the terminal screens in Ubuntu, and after a bit of Googling, here’s the answer…

From Ubuntu Forums by Nythain:

you need to edit your /boot/grub/menu.lst file and make a couple appropriate changes.

first, figure out what vga=XXX mode you want, this will determine the resolution, you can find a chart easily enough online anywhere by googling “grub resolution chart” or something similar.

then, you would edit the above mentioned grub file, and look for a line that looks like
#defoptions=quiet splash
though quiet and splash might not be there, who knows… but add right after it, vga=XXX so it looks like
#defoptions=quiet splash vga=XXX

now you could stop here, save the file, and sudo update-grub, which will create a new menu.lst using the automagic settings, including the vga=XXX that you added.

reboot, and voila, hopefully a much more readable TTY

As for the grub vga values, I found this at justlinux forums

depth------640x480-----800x600-----1024x768-----1280x1024
256----------769----------771-----------773-------------775
32000-------784----------787-----------790-------------793
65000-------785----------788-----------791-------------794
16.7 Mill.----786----------789-----------792-------------795

I edited /boot/grub/menu.lst several times until I found the best value which works on my computer. Sadly, 1280×1024 wouldn’t work, so eventually I settled for 1024×768, which is still a big improvement for me. What I finally ended up with is the following entry:

title Ubuntu 8.04.1, kernel 2.6.24-19-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=56070267-fb16-4318-a9ce-3dd7d8d5253b ro quiet splash vga=791
initrd /boot/initrd.img-2.6.24-19-generic

Use that as an example to understand what I changed, but for goodness sake, don’t copy and paste it, there’s a good chance it won’t work for you, and you may not be able to boot anymore.

After making the change, all I did was reboot, and it worked. I didn’t need to run sudo update-grub like the forum suggested… I’m not sure if you need to or not. Read the man page, I can’t be bothered.


Follow

Get every new post delivered to your Inbox.