From e7786d9b1904ecd2c9989c3f157df48016b0dd50 Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Mon, 18 Oct 2021 23:09:28 -0500 Subject: moved some things around --- keyboard/virt | 2 +- launch/chrome | 1 + launch/emu | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ launch/launch | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ launch/tserv | 13 +++++++++++++ misc/emu | 51 ------------------------------------------------- misc/launch | 54 ---------------------------------------------------- misc/mime | 51 +++++++++++++++++++++++++++++++++---------------- misc/pullsite | 5 ----- misc/tserv | 13 ------------- misc/wifitoggle | 34 --------------------------------- programs/chrome | 1 - st/settitle | 3 --- sync/pushsite | 5 +++++ sync/sinkold | 48 ++++++++++++++++++++++++++++++++++++++++++++++ video/.transtape.swp | 0 x11/capsmap | 1 - x11/settitle | 3 +++ 18 files changed, 211 insertions(+), 179 deletions(-) create mode 120000 launch/chrome create mode 100755 launch/emu create mode 100755 launch/launch create mode 100755 launch/tserv delete mode 100755 misc/emu delete mode 100755 misc/launch delete mode 100755 misc/pullsite delete mode 100755 misc/tserv delete mode 100755 misc/wifitoggle delete mode 120000 programs/chrome delete mode 100755 st/settitle create mode 100755 sync/pushsite create mode 100755 sync/sinkold delete mode 100644 video/.transtape.swp create mode 100755 x11/settitle diff --git a/keyboard/virt b/keyboard/virt index 446bfb3..2ab943e 100755 --- a/keyboard/virt +++ b/keyboard/virt @@ -2,7 +2,7 @@ virtdir=~/.local/share/virt halfram() { awk '/^MemTotal/ { printf "%dM\n", $2/2/1024 }' /proc/meminfo; } # Needs to be either in M or G according to man page -halfthreads() { awk '/^processor/ { cpus++ } END{ print cpus/2 }' /proc/cpuinfo; } +halfthreads() { echo $(( $(nproc) / 2 )); } startvm() { qemu-system-x86_64 \ -enable-kvm \ diff --git a/launch/chrome b/launch/chrome new file mode 120000 index 0000000..1fcdd6b --- /dev/null +++ b/launch/chrome @@ -0,0 +1 @@ +../../lib/ungoogled-chromium/chrome \ No newline at end of file diff --git a/launch/emu b/launch/emu new file mode 100755 index 0000000..df24b10 --- /dev/null +++ b/launch/emu @@ -0,0 +1,51 @@ +#!/bin/sh + +# This only works for collections with a common extension. You can rename all your roms to use the same extension and (in any decent emulator at least) they should work regardless of the actual header type +gamedir=${XDG_DATA_HOME:-$HOME/.local/share}/games +dmenuprompt="dmenu -l 25" +resolution=`cat /sys/class/drm/*/modes | head -1` +case "$1" in + 2600) + dmenucolors="-nb #111 -nf #e4963c -sb #6c3b17 -sf #fff -nhb #121212 -nhf #fc5231 -shb #804f2d -shf #fc5231" + emulator="stella" + ext=bin + ;; + 3ds) + dmenucolors="-nb #111 -nf #888 -sb #999 -sf #F00 -nhb #111 -nhf #fff -shb #999" + emulator="citra" + ext=3ds + ;; + nes) + dmenucolors="-nb #6d6a6d -nf #fff -sb #dfdcdd -sf #c1121c -nhb #222 -nhf #dc444d -shb #a29fa3 -shf #dc444d" + emulator="fceux" + ext=nes + ;; + snes) + dmenucolors="-nb #b2b4b2 -nf #000 -sb #514689 -sf #fff -nhb #707372 -nhf #fff -shb #a7a4e0 -shf #000" + emulator="launch snes" + ext=sfc + ;; + n64) + dmenucolors="-nb #223 -nf #fff -sb #069330 -sf #fff -nhb #c20d02 -nhf #ffc001 -shb #011da9 -shf #ffc001" + emulator="mupen64plus --fullscreen --gfx mupen64plus-video-glide64mk2 --resolution $resolution" + ext=z64 + ;; + gcn) + dmenucolors="-nb #4d3b7c -nf #ddd -sb #000 -sf #fff -nhb #4d3b7c -nhf #eba982 -shb #000 -shf #eba982" + emulator="dolphin-emu -b" + ext=iso + ;; + nds) + dmenucolors="-nb #ccc -nf #000 -sb #52398d -sf #fff -nhb #888 -nhf #fff -shb #52398d" + emulator="desmume --3d-engine 2" + ext=nds + ;; + *) + console=`ls $gamedir | dmenu -l 25` && ($0 $console || emu) # Allows going back to select a different console + exit + ;; +esac + +gamedir="$gamedir/$1" && [ -e "$gamedir" ] \ + && selgame="`ls "$gamedir" | sed -n "s/\.$ext$//p" | $dmenuprompt $dmenucolors`.$ext" \ + && $emulator "$gamedir/$selgame" diff --git a/launch/launch b/launch/launch new file mode 100755 index 0000000..0e2745e --- /dev/null +++ b/launch/launch @@ -0,0 +1,54 @@ +#!/bin/sh +[ -n "$2" ] && args=`echo "$@" | cut -d' ' -f2-` + +launchother() { $@ || echo "Launch: $@: Does not exist or exited with an error"; } + +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 + ;; + openbsdx230) + case "$1" in + brave) + ;; + chromium|chrome) + ;; + halt|off|poweroff|shutdown) doas halt ;; + sleep|suspend|zzz) doas zzz ;; + reboot|res|restart) doas reboot ;; + snes|snes9x) snes9x-gtk $args ;; + *) launchother $@ ;; + esac + ;; + *) echo "Launch: The hostname \"`hostname`\" is not recognized. Please add an entry for it!" ;; +esac diff --git a/launch/tserv b/launch/tserv new file mode 100755 index 0000000..5e0d072 --- /dev/null +++ b/launch/tserv @@ -0,0 +1,13 @@ +#!/bin/sh +server=~/.local/share/Terraria/server/TerrariaServer.bin.x86_64 +#wldnum=1 + +$server +#$server << CMDS +#$wldnum +#16 +#7777 +#n +# +#say hello +#CMDS diff --git a/misc/emu b/misc/emu deleted file mode 100755 index df24b10..0000000 --- a/misc/emu +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -# This only works for collections with a common extension. You can rename all your roms to use the same extension and (in any decent emulator at least) they should work regardless of the actual header type -gamedir=${XDG_DATA_HOME:-$HOME/.local/share}/games -dmenuprompt="dmenu -l 25" -resolution=`cat /sys/class/drm/*/modes | head -1` -case "$1" in - 2600) - dmenucolors="-nb #111 -nf #e4963c -sb #6c3b17 -sf #fff -nhb #121212 -nhf #fc5231 -shb #804f2d -shf #fc5231" - emulator="stella" - ext=bin - ;; - 3ds) - dmenucolors="-nb #111 -nf #888 -sb #999 -sf #F00 -nhb #111 -nhf #fff -shb #999" - emulator="citra" - ext=3ds - ;; - nes) - dmenucolors="-nb #6d6a6d -nf #fff -sb #dfdcdd -sf #c1121c -nhb #222 -nhf #dc444d -shb #a29fa3 -shf #dc444d" - emulator="fceux" - ext=nes - ;; - snes) - dmenucolors="-nb #b2b4b2 -nf #000 -sb #514689 -sf #fff -nhb #707372 -nhf #fff -shb #a7a4e0 -shf #000" - emulator="launch snes" - ext=sfc - ;; - n64) - dmenucolors="-nb #223 -nf #fff -sb #069330 -sf #fff -nhb #c20d02 -nhf #ffc001 -shb #011da9 -shf #ffc001" - emulator="mupen64plus --fullscreen --gfx mupen64plus-video-glide64mk2 --resolution $resolution" - ext=z64 - ;; - gcn) - dmenucolors="-nb #4d3b7c -nf #ddd -sb #000 -sf #fff -nhb #4d3b7c -nhf #eba982 -shb #000 -shf #eba982" - emulator="dolphin-emu -b" - ext=iso - ;; - nds) - dmenucolors="-nb #ccc -nf #000 -sb #52398d -sf #fff -nhb #888 -nhf #fff -shb #52398d" - emulator="desmume --3d-engine 2" - ext=nds - ;; - *) - console=`ls $gamedir | dmenu -l 25` && ($0 $console || emu) # Allows going back to select a different console - exit - ;; -esac - -gamedir="$gamedir/$1" && [ -e "$gamedir" ] \ - && selgame="`ls "$gamedir" | sed -n "s/\.$ext$//p" | $dmenuprompt $dmenucolors`.$ext" \ - && $emulator "$gamedir/$selgame" diff --git a/misc/launch b/misc/launch deleted file mode 100755 index 0e2745e..0000000 --- a/misc/launch +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -[ -n "$2" ] && args=`echo "$@" | cut -d' ' -f2-` - -launchother() { $@ || echo "Launch: $@: Does not exist or exited with an error"; } - -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 - ;; - openbsdx230) - case "$1" in - brave) - ;; - chromium|chrome) - ;; - halt|off|poweroff|shutdown) doas halt ;; - sleep|suspend|zzz) doas zzz ;; - reboot|res|restart) doas reboot ;; - snes|snes9x) snes9x-gtk $args ;; - *) launchother $@ ;; - esac - ;; - *) echo "Launch: The hostname \"`hostname`\" is not recognized. Please add an entry for it!" ;; -esac diff --git a/misc/mime b/misc/mime index 2070376..5951b14 100755 --- a/misc/mime +++ b/misc/mime @@ -1,7 +1,9 @@ #!/bin/sh +# Media type csv caching cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mimewiz" -types="`grep -v '#'`"<< TYPES -application +mtypesrc="https://www.iana.org/assignments/media-types" +mtypes="`grep -v '#'`"<< TYPES +#application audio font #example @@ -12,36 +14,53 @@ image text video TYPES -typesrc="https://www.iana.org/assignments/media-types" -#dlcsv() { curl -sS -C - -e "$typesrc" "$typesrc" > "$typefile" || exit; } dlcsv() { curl -sS -C - -o "$2" "$1" || exit; } # Download all media type csv's if they're not avaliable mkdir -p "$cachedir" -for type in $types; do - typefile="$cachedir/$type.csv" - [ -e "$typefile" ] || dlcsv "$typesrc/$type.csv" "$typefile" +for mtype in $mtypes; do + mtypefile="$cachedir/$mtype.csv" + [ -e "$mtypefile" ] || dlcsv "$mtypesrc/$mtype.csv" "$mtypefile" #[ "$2" = "$type" ] && mimetype="`cut -d',' -f2 $typefile`" && break done -#[ -n "$mimetype" ] && xdg-mime default $application.desktop $mimetype +interactiveopt() { # Usage: interactiveopt "options" "prompt" "maxopts" "col" + unset opt # This won't be set if we choose to use recursion, so do it in a while loop instead + while [ -z $opt ] 2>/dev/null; do + [ -n "$4" ] && [ "$4" = "col" ] \ + && echo "$1" | nl -s': ' | column \ + || echo "$1" | nl -s': ' + read -p "$2" choices \ + && [ -n "$3" ] && ( choices="$(echo $choices | cut -d' ' -f1-$3)" || ( echo "Invalid entry" && unset choices ) ) + for choice in $choices; do + case "$choice" in + [0-9]*) opt="$(echo "$1" | head -"$(echo $choice | tr -cd '[:digit:]')" | tail -1) $opt" ;; + *) opt="$(echo "$1" | grep "^$choice$" 2>/dev/null) $opt" ;; + esac || ( echo "Invalid option \"$choice\"" && undet opt && break ) # Why wont this unset opt or break??????? + done + done +} -# Choose mimetype: -types="$types\npdf\nspreadsheet ms-excel\nwordprocessing ms-word\npresentation ms-powerpoint\ndrawing\nzip gzip" -echo "$types" | nl -s': ' -echo "$types" | head -7 | tail -1 +# Choose mimetype: +mtypes="$mtypes\npdf\nspreadsheet ms-excel\nwordprocessing ms-word\npresentation ms-powerpoint\ndrawing\nzip gzip" +interactiveopt "$mtypes" "Choose Mimetype: " +mtype="$opt" +echo "$mtype" # Choose subtype #cut -d',' -f1 "$cachedir/application.csv" | grep drawing | nl -s': ' | column # Choose program -ls /usr/share/applications | sed 's/\.desktop//' | nl -s': ' | column +interactiveopt "$(ls /usr/share/applications | sed 's/\.desktop//')" "Choose program to open with: " col +program="$opt" +echo "$program" - -#cut -d',' -f1 "$cachedir/image.csv" | nl -s': ' | column -cut -d',' -f2 "$cachedir/image.csv" +#echo "All $mtype Types\n$(cut -d',' -f1 "$cachedir/image.csv" | tail -n +2)" +#cut -d',' -f2 "$cachedir/image.csv" #jcho "$types" | while read type; do #done + +#[ -n "$mimetype" ] && xdg-mime default $application.desktop $mimetype diff --git a/misc/pullsite b/misc/pullsite deleted file mode 100755 index 4507256..0000000 --- a/misc/pullsite +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -ssh root@tjkeller.xyz << EOF -cd /var/www/tjkeller/ -git pull -EOF diff --git a/misc/tserv b/misc/tserv deleted file mode 100755 index 5e0d072..0000000 --- a/misc/tserv +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -server=~/.local/share/Terraria/server/TerrariaServer.bin.x86_64 -#wldnum=1 - -$server -#$server << CMDS -#$wldnum -#16 -#7777 -#n -# -#say hello -#CMDS diff --git a/misc/wifitoggle b/misc/wifitoggle deleted file mode 100755 index 4c74da4..0000000 --- a/misc/wifitoggle +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -printusage() { echo "Usage: $0 [up|on|down|off|toggle]" && exit; } -if [ "$COMPUTER" = "laptop" ]; then - down() { - doas sv stop dhcpcd sshd rsyncd - } - up() { - doas sv start dhcpcd sshd rsyncd - } - toggle() { - case `doas sv status dhcpcd | cut -d':' -f1` in - run) down ;; - down) up ;; - *) echo "Error: sv returned an invalid string. Is dhcpcd being used on this system? Is runit the init system?" ;; - esac - } -elif [ "$COMPUTER" = "desktop" ]; then - down() { - echo hi; - } - up() { - echo hi; - } -fi - -[ -z "$1" ] && toggle && exit - -case "$1" in - up|on) up ;; - down|off) down ;; - toggle) toggle ;; - *) printusage ;; -esac - diff --git a/programs/chrome b/programs/chrome deleted file mode 120000 index 1fcdd6b..0000000 --- a/programs/chrome +++ /dev/null @@ -1 +0,0 @@ -../../lib/ungoogled-chromium/chrome \ No newline at end of file diff --git a/st/settitle b/st/settitle deleted file mode 100755 index df613ca..0000000 --- a/st/settitle +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -xdotool getactivewindow set_window --class "$1" -[ -z "$2" ] && echo -en "\e]0;$2\a" diff --git a/sync/pushsite b/sync/pushsite new file mode 100755 index 0000000..4507256 --- /dev/null +++ b/sync/pushsite @@ -0,0 +1,5 @@ +#!/bin/sh +ssh root@tjkeller.xyz << EOF +cd /var/www/tjkeller/ +git pull +EOF diff --git a/sync/sinkold b/sync/sinkold new file mode 100755 index 0000000..3022963 --- /dev/null +++ b/sync/sinkold @@ -0,0 +1,48 @@ +#!/bin/sh + +printusage() { echo "Usage: $0 [ ...] (repos: all,`echo $repos | tr ' ' ','`) [up|down]" && exit; } + +repos="docs patches" + +oper=`echo $@ | sed 's/.* //'` # Get last argument +([ -z $2 ] || ([ "$oper" != "up" ] && [ "$oper" != "down" ])) && printusage + +# rync options +#fix this too +ropts="--archive --partial --progress --recursive --update --verbose" # Equivalent to: -aPrvu --delete +rdest="tjkrsync@tjkeller.xyz:" + +# Colors +BOLD="\033[1m" +NORM="\033[0m" +CYN="\033[0;36m" +RED="\033[0;31m" +GRN="\033[0;32m" + +printsyncmsg() { echo -n "$CYN[Syncing $SYNCNAME...]$NORM\n"; } +printsuccess() { echo -n "$BOLD$GRN[Successfully synced $SYNCNAME]\n"; } +printerror() { echo -n "$BOLD$RED[An error occured while syncing $SYNCNAME]\n"; } + +sync() { + [ $oper = "up" ] && SYNCNAME="$1$2 to $rdest$2" || SYNCNAME="$rdest$2 to $1$2" + printsyncmsg + (if [ $oper = "up" ]; then rsync $ropts $1$2 $rdest; else rsync $ropts --delete $rdest$2 $1; fi) \ + && printsuccess || printerror +} + +# arg1 = options + containing directory path, arg2 = file/directory name +syncdocs() { destdir="" && sync "/home/timmy/docs/" "school"; } +#syncsites() { destdir="" && sync "--exclude=pass /home/timmy/.local/src/" "sites"; } # Excludes password file +syncpatches() { destdir="" && sync "--exclude=.git /home/timmy/.local/src/programs/" "patches"; } # Excludes git files + +for arg in "$@"; do + case $arg in + all) $0 $repos $oper ;; + up|down) oper=$arg ;; + *) # Would like to use something like $repos) here but cant + for repo in $repos; do + [ "$arg" = "$repo" ] && sync$arg && break + done || printusage + ;; + esac +done diff --git a/video/.transtape.swp b/video/.transtape.swp deleted file mode 100644 index e69de29..0000000 diff --git a/x11/capsmap b/x11/capsmap index ad107da..36c5eb1 100755 --- a/x11/capsmap +++ b/x11/capsmap @@ -1,5 +1,4 @@ #!/bin/sh - # Remap caps to super when held setxkbmap -option caps:super # Remap caps to escape when pressed diff --git a/x11/settitle b/x11/settitle new file mode 100755 index 0000000..df613ca --- /dev/null +++ b/x11/settitle @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +xdotool getactivewindow set_window --class "$1" +[ -z "$2" ] && echo -en "\e]0;$2\a" -- cgit v1.2.3