mirror of https://git.sr.ht/~skiqqy/bin
parent
c328065251
commit
4c21af99a1
@ -1,19 +1,29 @@ |
||||
#!/bin/bash |
||||
# Simple script that uses dmenu to get input, and then invokes killall -9 <input> |
||||
#!/usr/bin/env bash |
||||
# Kill programs, using dmenu to get input |
||||
|
||||
SCRIPT_PATH=$(dirname $0) |
||||
. "$SCRIPT_PATH/import/alert.sh" > /dev/null 2>&1 |
||||
[ ! $(command -v error) ] && echo "[WARNING] Missing 'error.sh' import." |
||||
[ ! $(command -v dmenu) ] && error "Missing 'dmenu' dependency." |
||||
declare -A map |
||||
|
||||
# Use dmenu to get input |
||||
dmenui () { |
||||
dmenu << EOF |
||||
EOF |
||||
} |
||||
# Setup accronyms |
||||
map[tg]=telegram-desktop |
||||
map[cord]=Discord |
||||
map[spot]=spotify |
||||
|
||||
input=$(dmenui) |
||||
# Get input |
||||
input=$(printf '' | dmenu) |
||||
|
||||
[ -z $input ] && error "No input provided" 1 || echo "Killing $input" |
||||
# Translate |
||||
kill=( ) |
||||
for prog in $input |
||||
do |
||||
if [ -n "${map[$prog]}" ] |
||||
then |
||||
kill+=( "${map[$prog]}" ) |
||||
else |
||||
kill+=( "$prog" ) |
||||
fi |
||||
done |
||||
|
||||
killall -9 $input |
||||
[ -z "$input" ] && exit |
||||
|
||||
echo "Killing ${kill[*]}" |
||||
killall -9 "${kill[@]}" |
||||
|
Loading…
Reference in new issue