Nice global environment variable additions

Since my vacation is coming to an end I thought I’d leave a nice little trick on how to administrate a number of environment variable additions for all users on the system.

Sure, there is the /etc/environment file but it seems rather limiting to me. I needed a little more control, so I came up with the following the little scripting:

Create a new folder /etc/environment.imports, in the folder just have a ordered/leveled number of scripts (i.e. 01_qt, 02_java). Add the following code to your /etc/profile:

# Custom PATH and LD_LIBRARY additions
xdg_source_list=`echo /etc/environment.imports/*`
for source_file in $xdg_source_list
do
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  source $source_file
done

Now you can just export all the necessary additions through the files in /etc/environment.imports:

#!/bin/sh
export LD_LIBRARY_PATH=/opt/wine/lib:$LD_LIBRARY_PATH
export PATH=/opt/wine/bin:$PATH
export PKG_CONFIG_PATH=/opt/wine/lib/pkgconfig:$PKG_CONFIG_PATH

export XDG_DATA_DIRS=/opt/wine/share:$XDG_DATA_DIRS

This way it’s extremely easy to maintain a large number of custom-prefixed software for a complete system without touching the user’s custom profile.

Using twhirl on Linux – the nice way

Without any doubt twhirl is the greatest twitter client available. It’s an Air-based application – meaning you can even use it on Linux.

Now, as you may know KDE 4.1 comes with a handy little twitter client plasmoid itself but the functionality is really limited, the plasmoid is a little buggy and overall can’t compete with twhirl. So, let’s install twhirl then, eh?

First thing you have to do is installing the Adobe Air for Linux alpha. Since the installation is pretty straightforward and the package is an RPM I’ll skip the details.

After installing Air just navigate to the twirl website, look for the “manual installation” paragraph on the right handside and click “Download and install the latest twhirl release”. The installation will start and you’ll be able to start the application afterwards by executing (if you installed it to /opt) /opt/twhirl/twhirl.

You probably want to get rid of the pesky taskbar entry now: With KWin all you’ve to do is press ALT+F3, select Configure Window Behaviour and choose “Window Specific” in the dialog. Create a new rule by clicking New, click “Detect Window Properties” and select the twirl window. Just accept the settings in the upcoming dialog, and close it. Time to edit the rules a bit: Double click the new rule in the list, go to the Preferences tab and select “Keep below”, “Skip taskbar”, select “Force” for each item and don’t forget to enable the checkbox at the end. Apply the settings and voila – a nice, widget-like twirl on your Linux desktop.

The nice thing about twhirl is that it comes with different color schemes and the “Black Magic” colorset matches the dark Oxygen plasma theme almost perfectly.

Yeah, this post is pretty sketchy, I wish I could upload media to illustrate it – but that functionality is still broken.

Copying User profiles while in use

I know it’s not a feasable way to do it but sometimes you can’t get around to copy a user profile while it’s still locked (think: Windows locks it even after the user logs out).

To copy such a pesky profile I use Hobocopy:

hobocopy /full /y /r “%HOMEDRIVE%\%HOMEPATH%” “C:\UserProfileBackup”

The program makes use of shadow copies to perform the process so the resulting file will still be locked but at least it was copied. This becomes quite useful when used in conjunction with, for instance, the portable version of CCleaner and it’s /AUTO switch.

Limit CPU consumption of applications on Linux

One of the more frequent questions in support channels: How do I limit a specific application to not consume all my cpu time?

While it is generally a bad idea to limit applications in that department, it is indeed quite easy…

Install the tool cpulimit (most modern distributions should have a package ready in their repositories!) and launch it with the correct parameters:

cpulimit -P /usr/bin/foobar -l 10

The command above would wait for program /usr/bin/foobar to be started and limit the CPU consumption of the application to a maximum of 10%.

Note that without further configuration you’ll need to sudo cpulimit or start it as a root. The specified application can be started in a normal user context, though.

Moving folders to the server side

Wow, the second Windows-related post today? Something horrible must be happening to me right now…

Anyway, you may know a situation like this: Many clients, one server and a terribly stubborn application that just wants to write into that one pesky folder on the local hard disk. Needless to say that thanks to your policies that won’t last a reboot.

So, how can we tame applications like that? People want their data to be available across the network, in a central location/database. If the application’s data is not transaction-dependant you’re in luck.

Unix-lovers know hard-, soft- and symlinks. Hardlinks are available on Windows XP as well, but the truly wonderful stuff comes in on Vista: You get the two other missing types.

That doesn’t mean that XP users are left in the cold, you can download the necessary tool from various sources on the net for free and give it a shot.

So, what is this mysterious tool? It comes with Vista and is called MKLINK. Just use it like this:

mklink /D "Damn local database folder" "\\SERVER\DatabaseFolder"

Yes, we can actually point to a UNC path and — given the client users have sufficient rights — will be able to browse the folder just like any other folder on your file system. That’s pretty sweet and incredibly useful for ol’ haggy applications.

Don’t forget that this operation (just like everything fun) requires elevated access to do!