Getting presets onto X clipboard(s)

Here’s one thing I find really useful – being able to get presets onto the current X clipboard(s) via a hotkey, for stuff like the current timestamp in different formats.

What you’ll need is "xsel" – just install it through aptitude (or your favorite package manager).

Once installed, you can then make a script like this:

# Display a menu like:
# a - 20080715T025257
# b - 2008-07-15 @ 02:52:57
# c - 2008-07-15
# Selection: a

echo "a - $(date "+%Y%m%dT%H%M%S")
b - $(date "+%F @ %H:%M:%S")
c - $(date "+%F")"

read -p "Selection: " selection

case $selection in
		# 20080715T030047
		text=$(date "+%Y%m%dT%H%M%S")
		# 2008-07-15 @ 03:00:47
		text=$(date "+%F @ %H:%M:%S")
		# 2008-07-15
		text=$(date "+%F")
		# 20080715T030047
		text=$(date "+%Y%m%dT%H%M%S")

echo -n "$text"|xsel -p
echo -n "$text"|xsel -b

And assign it to a hotkey via a command like:

xfce4-terminal -x [fullPathToScript]/

Now just press your hotkey, hit [Enter] and you now have the current time in ISO 8601 format on your clipboard!

Oh, and you can also use xsel to do other things – like copying a file’s name / full path from your favorite file-manager’s context menu. For example, in Xubuntu (with Thunar) (you set this in "Edit → Configure custom actions…"):

Name:	 Copy _Full path		# The "_" is for the key accelerator.
Command: xfce4-terminal -x [fullPathToScript]/ %f
-------- And --------
Name:	 Copy file _name
Command: xfce4-terminal -x [fullPathToScript]/ %n
# Don't forget to set the "Appearance Conditions" (tab) for all files!


echo -n $1|xsel -b

You should now be able to copy the file’s full path from the context menu – I find it very useful for getting the full path of a file for file uploads.

Now, it’d be even cooler if we can extend this with the history of the X clipboards – if anyone have an idea how I can do this, please drop me a comment! – Or more precisely, how to collect the history of the X clipboards for use.


DSpace resource_type_id

For those of you who are wondering what the values in "resource_type_id" stands for (for example, in the "resourcepolicy" table), here is what I’ve found out:

0 = bitstream
1 = bundle
2 = item
3 = collection
4 = community

I’d welcome anyone who can point me to the documentation of this – I tried but I couldn’t find it…

I only know the above information after comparing DB dumps… (which is actually what I’ve had to do to figure out what DSpace is doing to its DB schema for everything… But hey, that was (ahem…) "fun" and now I know how to use "diff" ;-) !).

Posted in Tips. 2 Comments »

Command line to change mouse speed in X

Here’s a quick tip, to change the mouse speed using command-line under X, use the "xset" command.

For example:

xset mouse 38/10 2		# I use this setting on my 1920x1200 LCD.

You can of course get more information by the usual "man xset" command.

And yes, xset does more – things like turning the display off, setting the keyboard LEDs, keyboard autorepeat settings etc… – check the manual out!

Here’s what I use to turn my screen off – assign that to a hotkey / command and voila, you now have a virtual "off" button for your LCD!:

xset -display :0 dpms force off

Amazing Grace

This is such an amazing song – only recently had I been able to really connect with the lyrics.

Amazing grace, how sweet the sound
That saved a wretch like me,
I once was lost but now am found,
Was blind but now I see.

'Twas grace that taught my heart to fear
And grace my fears relieved,
How precious did that grace appear
The hour I first believed.

My chains are gone, I've been set free,
My God, my saviour has ransomed me,
And like a flood his mercy reigns,
Unending love, amazing grace.

The Lord has promised good to me,
His word my hope secures,
He will my shield and portion be
As long as life endures.

My chains are gone, I've been set free,
My God, my saviour has ransomed me,
And like a flood his mercy reigns,
Unending love, amazing grace.

The earth shall soon dissolve like snow,
The sun forbear to shine,
But God who called me here below
Will be forever mine,
Will be forever mine,
You are forever mine.

I have to admit, every time I sing this song in a church service, my eyes always fill up with tears – because what is in the song is simply so wonderfully true.

Here is the song performed by the author, Chris Tomlin: