Archive for April, 2009

Switch Host – local/remote hostname lookup

Monday, April 27th, 2009

Switch_host is a tool that let you handle and configure a hostname lookup. Configuring the makefile, you tell switch_host what is the IP address to work with.
Switch_host is useful when you have a local server, and you want to use it either when you are at home or when you are out. Instead of modifing /etc/hosts by hand, switch_host will do it for you.

Usage: switch_host [options]

Options:
-a | --actual      Show current setting
-d | --dynamic     Set dynamic host
-h | --help        Print this message
-s | --static      Set static host

Check out the README file for any helps.

Follow the project in the repository under the name: switch_host.

Hotkeysd – hotkeys daemon

Monday, April 27th, 2009

Running dwm, i needed a piece of code for the management of fn-keys. So i ended with a client/daemon application capable of doing stuff such as disabling wifi, toggle the lvds backlight, increase/decrease volume ecc ecc. The communication method is always the same: a shared fifo placed in /tmp.
Because of the need of running commands with root privileges, i added a small c launcher (hotkeys_launcher), which makes use of the ’s’ bit for invoking the daemon as super-user.
In order to use the scripts you need these programs: xrandr, amixer, xbacklight, system_info (previous post), osdc/osdd (previous post), hibernate, hibernate-ram.
Just for taste, here is the help message displayed with the client-side app:

usage: hotkeysc [option]

option:
B+	increase brightness
B-	decrease brightness
Bt	turn off/on brightness
G	change cpu governor
H	hybernate
h	print this message
I	displays general informations (cpu-load, temperature..)
M	switch to external monitor
R	restart the daemon
S	suspend
Td	disable trackpad
Te	enable trackpad
V+	increase volume level
V-	decrease volume level
Wt	enable/disable wifi interface

Before using the launcher inside your .xinitrc file, try the daemon in a shell in order to debug errors due to programs not found ecc ecc.
Here is my .xbindkeysrc file configured for hotkeysc/d:

# Brightness Up
"hotkeysc B+"
	m:0x0 + c:233
	XF86MonBrightnessUp

# Brightness Down
"hotkeysc B-"
	m:0x0 + c:232
	XF86MonBrightnessDown

# Brightness Toggle
"hotkeysc Bt"
	m:0x0 + c:156
	XF86Launch1

# Governor
(xbindkey "hotkeysc G")
	m:0x0 + c:210
	XF86Launch3

# Info
(xbindkey "hotkeysc I")
	m:0x0 + c:244
	NoSymbol

# Monitor switch
(xbindkey "hotkeysc M")
	m:0x0 + c:235
	XF86Display

#--------------------------------------------------
# # Suspend
# (xbindkey "hotkeysc S")
# m:0x0 + c:223
#--------------------------------------------------

# Trackpad toggle
xbindkey "hotkeysc Tt")
	m:0x0 + c:200
	NoSymbol

# Volume Up
"hotkeysc V+"
	m:0x0 + c:123
	XF86AudioRaiseVolume

# Volume Down
"hotkeysc V-"
	m:0x0 + c:122
	XF86AudioLowerVolume

# Volume Toggle
"hotkeysc Vt"
	m:0x0 + c:121
	XF86AudioMute

# Wifi toggle
(xbindkey "hotkeysc Wt")
	m:0x0 + c:246
	NoSymbol

You can grab the source from the repository under the project name hotkeysd.

OSDD – on screen display daemon

Sunday, April 26th, 2009

While working with minimal windows manager (awesome, dwm), i created a simple client/daemon system useful for showing text on screen; i used it for temperature, cpu-usage, battery life remaining and stuff like that.
The communication system is based on a fifo placed by default in /tmp directory.
The daemon (osdd) could be invoked with some options that let you configure the appeal of the window.
The client is invoked considering that each argument will be printed on screen as a new line, i mean:

$ osdc "first line" "second line" foo3 foo4

has as effect an osd message composed by 4 lines.

You can get the sources from the repository: project name osdd.

System info from command-line

Sunday, April 26th, 2009

I often had come into the need of knowing informations from the running system (i.e. cpu load, memory usage or temperature).
One for all, i wrote down a script that collects few fuctions for grabbing these infos from the linux proc/sys file-system.
Remember to edit the script before the installation, in order to match your needs.

Usage: /usr/bin/system_info [-bdhlmnt]
    -b    prints battery info
    -d    prints date
    -h    prints this help
    -l    prints system load
    -m    prints memory usage
    -n    prints network stats
    -t    prints temperature

Take it from the svn repository: the project name is system_info.

Wordpress: avoid texturizer

Saturday, April 25th, 2009

Texturizer is a wordpress tool that give your post a sexier appealing.
Because of my frequent use of pre/code html tags for posting code, i decided to disable this wp feature: here is a small diff to show you how to achieve that.

--- wp-includes/formatting.php.old  2009-04-25 13:28:24.000000000 +0200
+++ wp-includes/formatting.php      2009-04-25 13:28:55.000000000 +0200
@@ -41,7 +41,7 @@
                $output .= $curl;
        }

-       return $output;
+       return $text;
 }

 // Accepts matches array from preg_replace_callback in wpautop()

Hope it is helpful for someone!