#!/usr/bin/perl # As is, this script is expected to be called from my .fvwm2rc ; output # is intended to go to some available console, just like any other WM # output. # # Nifty thing lovers will of course design funny X11 apps for displaying # all this... use POSIX qw(strftime floor); for $_ (@ARGV) { # These two do work. Kinda cool. /^AudioLowerVolume$/ && do { system "aumix -v-"; next; }; /^AudioRaiseVolume$/ && do { system "aumix -v+"; next; }; # This does not quite work yet. /^AudioMute$/ && do { system "aumix -v0"; next; }; # very very primitive... /^ToggleWireless$/ && do { system "ip link show eth1 | grep -qw UP && ifdown eth1 || ifup eth1"; }; # Need to elaborate on this one ;-))) /^Eject$/ && do {system "cdrecord dev=0,0,0 -eject >/dev/null 2>&1";}; # This satisfies me. /^BatteryInfo$/ && do { print "battery life:"; my ($cap,$rate)=(0,0); for my $battery ("BAT0","BAT1") { open F, ") { if (/^remaining capacity:\s+([0-9]+)(\s.*)$/) { $cap += $1; print " $battery:$1$2"; } if (/^present rate:\s+([0-9]+)(\s.*)$/) { $rate += $1; } } close F; } if ($rate) { my $sec=($cap*3600.0)/$rate; my $lstr=""; my $x; if ($sec >= 3600) { $x=floor($sec/3600); $lstr .= "$x" . "hr"; $sec = $sec - 3600 * $x; } $x=floor($sec/60); $lstr .= (sprintf "%02d", $x) . "mn"; printf " (%.1fW, $lstr remaining)", ($rate/1000.0); } else { print " (battery consumption unknown)"; } print "\n"; }; }