Domain migration

chrooted-universe.org => chroot-me.in

I decided to move all my web stuff, svn, and other services to my new domain chroot-me.in. I’ll keep chrooted-universe.org, but I would be grateful if you update your bookmarks, rss subscriptions and yours links to my website :)

Thanks!

HOWTO: Using a GNU screen inside another GNU screen

I found this feature this morning, and the irc folks being enthusiastic, I decided to blag about it.

I use GNU screen on a daily basis for almost three years. Not only able to provide an almost complete terminal emulation, with detach and reattach abilities, extensive keyboard bindings, tabs (a.k.a windows) management, Gnu screen is a versatile tool, although surprisingly more than often ignored by a lot of people.

There is a little reminder of what GNU screen consists in.

Requirements, or at least highly recommended setup

It is highly recommended to have a screenrc that provides a hardstatus line, the only practical way to distinguish one screen from another.

Here is mine:

shell /bin/zsh
attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' 
defbce "on"
term screen-256color
maptimeout 5
termcapinfo xterm* ti@:te@
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%{g} %l][%=%{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u
)%?%{r})%{w}%?%+Lw%?%?%=%{g}][%{B}%d/%m %{W}%c%{g}]'
defnonblock 5

Of course, you should adapt this to fit your needs, only the lines beginning with hardstatus are relevant there.

Now that your GNU screen is properly configured, I can highlight the bullet point of this howto :)

Pictures are said to help comprehension. I say LIES!

My X terminal emulator is Terminator. Combined with GNU screen, you can obtain … that…thing:

'what. the. heck?'

(click on the thumbnail to maximize)

Please bear with me, even if this caused some eye-melting :P

Some explanations: each zone delimited by light grey borders are in fact splits in Terminator. Gnu screen sessions are contained in the numbered splits.

1: err… not really a screen, I guess I’m tired and too lazy to correct the picture.

2: lwatch on dresda

3: lwatch on pandora

4: htop on dresda

5: htop on pandora

6: irssi on dresda

The only thing I had to do is to execute screen -e ^ee on pandora, therefore rebinding all default ^a (Ctrl+a) bindings to ^e (Ctrl+e).

Then you control the main screen with the default binding, while controlling the inner screen with these new binds (i.e ^ac to create a new window in the main screen, ^ec to do the same in the inner screen :)

Finally, the relevant part in man screen:

       -e xy
            specifies the command character to be x and the character generat‐
            ing a literal command character to y (when typed after the command
            character).  The default is "C-a" and `a', which can be  specified
            as  "-e^Aa".  When creating a screen session, this option sets the
            default command character. In a multiuser session all users  added
            will  start off with this command character. But when attaching to
            an already running session, this option changes only  the  command
            character  of  the  attaching  user.  This option is equivalent to
            either the commands "defescape" or "escape" respectively.

I really enjoy it, it’s like a Christmas present for all BOFHs, blinking like a Christmas Tree when some jerk is trying to mess with your servers/networks :D

Chrooted-timeout

chrooted-universe.org experienced a rather long blackout.

Indeed, the adsl line that usually allows my server to be reachable from the Internet faced a severe technical issue, resulting in a downtime of more than 5 days.

I can actually bear with it though, since the line is subscribed to a common-carrier, not a professional ISP.

Thus, I have decided to transfer chrooted-universe.org and some of its subdomains to a Gandi VPS.

The effective migration may happen this week, it will depend mostly on my available time (kind of busy this week).

I’ll give it a try for one month, but I am already quite surprised by the overall performance of a unique tiny share.

Sorry for the inconvenience.

Lenovo Thinkpad X300 , battery management and tp_smapi

This article briefly presents a « solution » to the battery switching issue mentioned at the bottom of this blog entry.

Indeed, while having two batteries ensures a (very) long battery life, you have to switch manually from the secondary battery to the primary, in order to prevent deep discharges that harms lithium batteries.

Until now, I used to manage it by typing some aliases in my shell, but it is clearly not convenient nor reliable (Sometimes, I simply forget it).

But now, one little bash script and one line in your root’s crontable, and the job’s done :)

There is battery_switch.sh (deprecated, see baswim.sh below). It basically allows automatic switching to main battery when a given percentage level is reached by the secondary battery. Some parameters are available by editing variables values directly in the script, but only LOW_LEVEL is really interesting.

The cron line I use:

# sudo crontab -e

# m h  dom mon dow   command
*/5 *   *   *   *   /opt/bin/battery_switch.sh

Of course it is aware of your laptop’s status. In fact, if it switched to the main battery (by forcing the main battery to discharge), and then you re-plug your laptop, it will cease to force discharge and will return to normal state.

Since I may not be clear, do a

tail -F /var/log/battery_switch.log

to get relevant information.

I hope that will help :)

EDIT: please find there baswim (battery switching improved) a new script that provides a *really* interesting feature: It permits to switch from one battery to another according to both remaining percentage and cycles count.

It follows this simple scheme:

1) Get batteries cycle status 
2) Decide which battery should discharge first based on cycles and remaining percentage
(above the low_level) 
3) Get AC status
3) If AC is unplugged, begin discharge with chosen battery
4) If needed by long unplugged operation, switch to the other battery

It basically a hack from the first script, there are some oddities (one line functions…) but hey it works (surprisingly)!

EDIT: A little but likely important update. This time, both scripts can handle two cases: one battery plus dvd-drive or both batteries.

EDIT:

If you want baswim to be a little more aware of acpi events,

you can make some symbolic links in /etc/acpi/battery.d and /etc/acpi/ac.d.

ln -s /opt/bin/baswim.sh /etc/acpi/battery.d/
ln -s /opt/bin/baswim.sh /etc/acpi/ac.d/

Then, baswim will be executed every time you plug or unplug your AC.