summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2022-01-05 12:28:43 -0600
committerTimmy Keller <tjk@tjkeller.xyz>2022-01-05 12:28:43 -0600
commit32d34ac9c5e3b682800f65f24743f2f29af04347 (patch)
tree741ed93d3e3ce188ec3cf1eda784b37bbc237a7d
parent673999f18f1c49e4178101d56a9293e0e20aade1 (diff)
downloadscripts-32d34ac9c5e3b682800f65f24743f2f29af04347.tar.xz
scripts-32d34ac9c5e3b682800f65f24743f2f29af04347.zip
change a few
-rwxr-xr-xlaunch/launch137
-rwxr-xr-xvideo/burndvd2
-rwxr-xr-xx11/xvsync2
3 files changed, 92 insertions, 49 deletions
diff --git a/launch/launch b/launch/launch
index e529438..cb06b1d 100755
--- a/launch/launch
+++ b/launch/launch
@@ -1,51 +1,94 @@
#!/bin/sh
-[ -n "$2" ] && args=`echo "$@" | cut -d' ' -f2-`
+me() { basename "$0"; }
+printhelp() {
+ echo "Usage:\n" \
+ " $(me): [-gh] [COMMAND] [COMMAND ARGS]...\n\n" \
+ "Args:\n" \
+ " -g: Force generate cache\n" \
+ " -h: show this help message\n\n" \
+ "Config Syntax:\n" \
+ " +host [HOSTNAME]\n" \
+ " Add a new host. Hosts can be referenced using their number starting with 1.\n" \
+ " [COMMAND]\n" \
+ " launch [COMMAND] will start the process specified for the specific hostname. Aliases are separated by |.\n" \
+ " [TAB][SHELL]\n" \
+ " Run this shell command when the above [COMMAND] is specified. In order of hostnames. Can be a number to reference to a hostname, a '-' to disregard this command for the specific host, or a '^' to reference the previous command."
+}
+gencache() {
+ awk '
+ BEGIN {
+ print "run=\"$1\"; shift"
+ print "case \"$run\" in"
+ }
+ {
+ sub(/#.*/, "") # Remove comments
+ if (!/^\s*$/) {
+ if (/^\+host/) {
+ sub(/\s*\+host\s*/, "")
+ h++
+ hosts[h] = $0
+ }
+ else {
+ if (!/^\t/) {
+ hostnum = 1
+ o++
+ opts[o] = $0
+ }
+ else {
+ sub(/^\t/, "")
+ if ($0 == "^")
+ $0 = cache
+ else if ($0 ~ /^[0-9]*$/)
+ $0 = cmds[hosts[$0]":"opts[o]]
+ cmds[hosts[hostnum]":"opts[o]] = cache = $0
+ hostnum++
+ }
+ }
+ }
+ }
+ END {
+ for (host in hosts) {
+ if (hosts[host] != "'`hostname`'")
+ continue
+ for (cmd in cmds) {
+ if (cmd ~ hosts[host] && cmds[cmd] && cmds[cmd] != "-") {
+ i = cmd
+ sub(/.*:/, "", cmd)
+ print "\t"cmd") "cmds[i]" \"$@\" ;;"
+ }
+ }
+ print "\t*) exit 1 ;;"
+ print "esac"
+ }
+ }
+ ' $conf > $cache
+}
-launchother() { $@ || echo "Launch: $@: Does not exist or exited with an error"; }
+# Config file setup
+confdir=${XDG_CONFIG_HOME:-~/.config}/launch
+conf=$confdir/config
+if [ ! -e $conf ]; then
+ mkdir -p $confdir
+ echo "#HOSTS\n+host $(hostname)\n\n#OPTS\ntest\n\techo \"Tested!\"" > $conf
+ echo "Config file created at $conf! Exiting"
+ echo
+ printhelp
+ exit 0
+fi
-case "`hostname`" in
- G3N2)
- case "$1" in
- brave) brave-bin $args & xdotool search --all --sync --class "brave-browser" set_window --class "Brave" --urgency 1 ;;
- chromium|chrome) chromium-browser $args & xdotool search --all --sync --class "Chromium-browser-chromium" set_window --class "Chrome" --urgency 1 ;;
- halt|off|poweroff|shutdown) doas poweroff ;;
- sleep|suspend|zzz) doas s2ram ;;
- reboot|res|restart) doas reboot ;;
- snes|snes9x) snes9x -fullscreen -xvideo $args ;;
- *) launchother $@ ;;
- esac
- ;;
- voidx250)
- case "$1" in
- brave) brave-browser-stable $args & xdotool search --all --sync --class "brave-browser" set_window --class "Brave" --urgency 1 ;;
- chromium|chrome) chrome $args & xdotool search --all --sync --class "Chromium-browser" set_window --class "Chrome" --urgency 1 ;;
- halt|off|poweroff|shutdown) doas poweroff ;;
- sleep|suspend|zzz) doas zzz ;;
- reboot|res|restart) doas reboot ;;
- snes|snes9x) snes9x-gtk $args ;;
- *) launchother $@ ;;
- esac
- ;;
- debx230)
- case "$1" in
- brave) brave-browser-stable $args & xdotool search --all --sync --class "brave-browser" set_window --class "Brave" --urgency 1 ;;
- chromium|chrome) chromium $args & xdotool search --all --sync --class "Chromium" set_window --class "Chrome" --urgency 1 ;;
- #halt|off|poweroff|shutdown) doas poweroff ;;
- #sleep|suspend|zzz) doas zzz ;;
- #reboot|res|restart) doas reboot ;;
- #snes|snes9x) snes9x-gtk $args ;;
- *) launchother $@ ;;
- esac
- ;;
- librex60)
- case "$1" in
- firefox|brave) iceweasel -P default-release ;;
- chromium|chrome) iceweasel -P School ;;
- halt|off|poweroff|shutdown) doas poweroff ;;
- #sleep|suspend|zzz) doas zzz ;;
- reboot|res|restart) doas reboot ;;
- *) launchother $@ ;;
- esac
- ;;
- *) echo "Launch: The hostname \"`hostname`\" is not recognized. Please add an entry for it!" ;;
+# Cache file setup
+cachedir=${XDG_CACHE_HOME:-~/.cache}/launch
+cache=$cachedir/cache
+[ ! -e $cache ] && mkdir -p $cachedir && gencache
+[ $conf -nt $cache ] && gencache
+
+# Command line options
+case "$1" in
+ -g) echo "Generating new cache: $cache"; gencache && cat $cache; exit ;;
+ -h) printhelp && exit ;;
+ '') printhelp && exit ;;
esac
+
+# Run
+#sh $cache "$@" || "$@" || echo "$(me): $@: Does not exist or exited with an error" &
+exec $cache "$@"
diff --git a/video/burndvd b/video/burndvd
index d8d6d76..af4b324 100755
--- a/video/burndvd
+++ b/video/burndvd
@@ -1,5 +1,5 @@
#!/bin/sh
-printusage() { echo "$0 [iso] [burner]"; }
+printusage() { echo "$(basename $0) [iso] [burner]"; }
if !(ls "$1" >/dev/null 2>/dev/null); then
echo "No iso selected or iso does not exist!"
printusage
diff --git a/x11/xvsync b/x11/xvsync
index 0d5cd5c..e80edab 100755
--- a/x11/xvsync
+++ b/x11/xvsync
@@ -1,5 +1,5 @@
#!/bin/sh
# Since this script runs xrandr to get the connected monitors, it is unnecessary to run xrandr by itself in your xinitrc
for monitor in `xrandr | sed -n 's/ connected.*//p'`; do
- xrandr --output $monitor --set TearFree ${1:-on}
+ #xrandr --output $monitor --set TearFree ${1:-on}
done