Commit Diff


commit - 04fc60225e5314129901e72eb80e86788db5d39c
commit + b8627881d887e30e2095ae3e269e097450500e03
blob - a6699539d22aac30e34397bd019523431ff30094 (mode 755)
blob + /dev/null
--- stimer.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-STATBARTIMER=~/.local/state/statbartimer
-
-show_help()
-{
-	echo "stimer help"
-	echo "\nstimer is used to set the statbar timer widget"
-	echo "statbar must be running for this program to be useful"
-	echo "\nUsage:"
-	echo "\tstimer <time>: count down from <time> in the status bar"
-}
-
-if [ ! -p "$STATBARTIMER" ]; then
-	echo "Could not open statbar timer" > /dev/stderr
-	exit 1;
-fi
-
-if [ -z "$1" ]; then
-	show_help;
-	exit 0;
-fi
-
-echo "$1" > "$STATBARTIMER"
-
blob - /dev/null
blob + 998fa4b9a0b2c8d702a31d6b8cce93a2fb5f85a2 (mode 755)
--- /dev/null
+++ stimer.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $timerpath = "$ENV{HOME}/.local/state/statbartimer";
+
+if (! -p $timerpath)
+{
+	die "Could not find statbartimer file or not FIFO";
+}
+
+$ARGV[0] =~ /^(?:\d{2}:(\d{2})|(\d+))$/ or die "Bad timer format";
+if ($1 > 59 or $2 > 5999)
+{
+	die "Bad timer format";
+}
+
+{
+	open my $fh, '>', $timerpath or die $!;
+	print $fh $ARGV[0];
+}
+