#!/bin/sh path=${0%/*}/${0##*.}.d action="$1" name="$2" command="$3" conffile="/usr/share/applications" case "$action" in add) grep -q "^$name " $conffile || echo "$name $command" >> $conffile ;; del) sed "/^$name /d" -i $conffile ;; get) cat $conffile exit 0 ;; *) echo "Usage: $0 {add | del | get}" >&2 exit 1 ;; esac shift 3 if [ -n "$1" ]; then while [ -n "$1" ]; do if [ -x "$path/$1" ]; then $path/$1 "$action" "$name" "$command" "$conffile" fi shift done else for script in `cd $path; ls 2>/dev/null | sort`; do $path/$script "$action" "$name" "$command" "$conffile" done fi