Package: fdpowermon
Version: 1.6
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Since fdpowermon is already tracking battery percentage, I thought it
would be nice to have a configuration option to run a command when
the level is <= a specified level.

Find attached a quick patch that implements running a command at a certain
threshold.

I've added
action = 80:sudo pm-suspend
to the config for testing, and it works :)


Cheers,
gregor

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBCAAGBQJQt8mjAAoJELs6aAGGSaoGeOEQALaekuWN+egAA5pKWvWjs4mh
Rpu4vEGlPoozgLkUAn63+oI+7As2/CAFGpXhMsI8Gia7VVW4GvHVrjeNEtACp1m/
relf/SydQr3hq+Nm16Ps3NhtC7LIcXmgTjKG3MoKJnRsLouucLZGDKxIzARCVaS2
jXyW7tL/Y763m9A/NpZl58qQVXeVB3WKza1MCvnCdfp99ZZeMsQVROMY3Lz8FxpQ
6OrLpeVFrt0SBXqWpbPJfN7n1q6hwAEicyfJw5u3hRmhQIcwphLPD9dHor8Vh//p
8cPZYPFNs2ICfAwCy098xnK5zc2DE/uuDyxQkhd0qGKyPXIl4ZxTZKCV8NIA/Stk
5v9E0Gdh2ikGA2SmxKWBL+p9jt+s/ZNIMpscuoE3C+aASl3V+1gOKT37ogO75hjM
rGP9G1DHkkeCIg0FBmdm2PULWyL4WnnUewdhzQrdiN9Hplp6PCUyJ00p2Evpk9cD
gglXtDW7hM0m9dERzMqsl5avoyZHu6c5D73Wif1EqTM/YkR9jwWFleD04vJzf4Fu
8D9JWOEF24gWZhQoHAoplgFDrCJDDgAlODEVXeHpy4iBXNyYA1qEMmhAxQDe6m21
W3GuZCD6I/3H1/uypn46QMq3e5w0aMt+crXjpiy69G3gXi0bfNjel/VJrDuRA34B
r+mAAfgIg4VlZA0xVdYI
=y4aM
-----END PGP SIGNATURE-----
--- /usr/bin/fdpowermon	2012-10-01 18:51:49.000000000 +0200
+++ fdpowermon	2012-11-29 21:37:26.979424371 +0100
@@ -90,6 +90,11 @@
 			$lastwarning=$flevel;
 		}
 	}
+	if(!$charging && 
+		defined($theme->{action_threshold}) && defined($theme->{action_command}) &&
+		$flevel <= $theme->{action_threshold}) {
+		system($theme->{action_command});
+	}
 	return 1;
 }
 
@@ -140,6 +145,8 @@
 			$curtheme->{charging} = parse_step($1, $curtheme->{steps});
 		} elsif($line=~ /dir\s*=\s*(.*)$/) {
 			$curtheme->{dir} = $1;
+		} elsif($line=~ /action\s*=\s*(.*)$/) {
+			($curtheme->{action_threshold},$curtheme->{action_command}) = split(/:/, $1);
 		}
 	}
 	$theme = $curtheme;

Reply via email to