Updated utils.
authorfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Sun, 20 Jul 2008 06:17:43 +0000 (06:17 +0000)
committerfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Sun, 20 Jul 2008 06:17:43 +0000 (06:17 +0000)
git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1115 959494ce-11ee-0310-bf91-de5d638817bd

icom-gen
planime
rbtadd
serialize.c [new file with mode: 0644]

index e724144..302fe63 100755 (executable)
--- a/icom-gen
+++ b/icom-gen
@@ -5,6 +5,7 @@ import Image
 
 if len(sys.argv) < 3:
     sys.stderr.write("usage: icom-gen INFILE OUTFILE\n")
 
 if len(sys.argv) < 3:
     sys.stderr.write("usage: icom-gen INFILE OUTFILE\n")
+    sys.exit(1)
 
 inf = Image.open(sys.argv[1])
 sz = inf.size
 
 inf = Image.open(sys.argv[1])
 sz = inf.size
diff --git a/planime b/planime
index b2b14dd..07bbb91 100755 (executable)
--- a/planime
+++ b/planime
@@ -157,6 +157,8 @@ if [ -r "$ifile" ]; then
            cmdline=("${cmdline[@]}" -delay "$arg")
        elif [ "$par" = aspect ]; then
            cmdline=("${cmdline[@]}" -aspect "$arg")
            cmdline=("${cmdline[@]}" -delay "$arg")
        elif [ "$par" = aspect ]; then
            cmdline=("${cmdline[@]}" -aspect "$arg")
+       elif [ "$par" = volmod ]; then
+           cmdline=("${cmdline[@]}" -af volume="$arg")
        elif [ "$par" = alang ]; then
            unset alang aid
            alang="$arg"
        elif [ "$par" = alang ]; then
            unset alang aid
            alang="$arg"
@@ -186,7 +188,7 @@ elif [ -n "$sid" ]; then
     cmdline=("${cmdline[@]}" -sid "$sid")
 fi
 
     cmdline=("${cmdline[@]}" -sid "$sid")
 fi
 
-if [ "`hostname`" = pc6 ]; then chwp=y; fi
+if [ "`hostname`" = pc6 -o "`hostname`" = pc7 -a "$DISPLAY" = :1 ]; then chwp=y; fi
 
 if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
 "${cmdline[@]}" "$file"
 
 if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
 "${cmdline[@]}" "$file"
diff --git a/rbtadd b/rbtadd
index 2a93557..25f6489 100755 (executable)
--- a/rbtadd
+++ b/rbtadd
@@ -7,9 +7,9 @@ fi
 
 for file in "$@"; do
     if [ -r "$file" ]; then
 
 for file in "$@"; do
     if [ -r "$file" ]; then
-       rsc pc17.dolda2000.com btadd - <"$file" && rm -f "$file"
+       rsc nerv.dolda2000.com btadd - <"$file" && rm -f "$file"
     elif [[ "$file" == http*://* ]]; then
     elif [[ "$file" == http*://* ]]; then
-       rsc pc17.dolda2000.com btadd "$file"
+       rsc nerv.dolda2000.com btadd "$file"
     else
        echo "rbtadd: $file: unreadable" >&2
     fi
     else
        echo "rbtadd: $file: unreadable" >&2
     fi
diff --git a/serialize.c b/serialize.c
new file mode 100644 (file)
index 0000000..4a851b1
--- /dev/null
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/file.h>
+
+int main(int argc, unsigned char **argv)
+{
+    int c;
+    int fd, locktype;
+    pid_t pid;
+    int status;
+    
+    locktype = LOCK_EX;
+    while((c = getopt(argc, argv, "se")) > 0)
+    {
+       switch(c)
+       {
+       case 's':
+           locktype = LOCK_SH;
+           break;
+       case 'e':
+           locktype = LOCK_EX;
+           break;
+       default:
+           return(1);
+       }
+    }
+    if(argc - optind < 2)
+    {
+       fprintf(stderr, "Wrong number of arguments\n");
+       return(1);
+    }
+    if((fd = open(argv[optind], O_RDWR | O_CREAT, 0600)) < 0)
+    {
+       perror(argv[optind]);
+       return(1);
+    }
+    optind++;
+    flock(fd, locktype);
+    if((pid = fork()) < 0)
+    {
+       perror("fork");
+       return(1);
+    } else if(!pid) {
+       execvp(argv[optind], argv + optind);
+       perror(argv[optind]);
+       exit(127);
+    }
+    while(wait(&status) != pid);
+    flock(fd, LOCK_UN);
+    return(status);
+}