backlog from void vm

This commit is contained in:
Cynthia Foxwell 2022-04-03 21:46:58 -06:00
parent 202df2947f
commit dd215a3ba0
21 changed files with 1825 additions and 23 deletions

View file

@ -0,0 +1,160 @@
#!/bin/bash
readonly prog_name="elixiremanager"
readonly prog_ver="7.0"
#defaults
readonly apiurl="https://elixi.re/api"
readonly apikey="$ELIXIRE_TOKEN"
mode=area
wayland=false
if [[ "$OSTYPE" == "darwin"* ]]; then
macos=true
else
macos=false
fi
is_admin=""
readonly filename_format="/tmp/elixire-$(date +%Y-%m-%dT%H:%M:%S).png"
readonly upload_connect_timeout="5"
readonly upload_timeout="120"
readonly upload_retries="1"
function usage() {
echo "usage: ${1} [options] [filename]"
echo "options:"
echo " -h, --help print this help and exit"
echo " -v, --version print version number and exit"
echo " --check check dependencies and exit"
echo " -a, --area select an area to upload"
echo " -f, --full upload the full screen"
echo " -k, --keep keep the file after uploading"
echo " -w, --wayland run in Wayland mode"
echo " -x, --xorg run in Xorg mode"
echo " --admin upload as an admin"
echo " --noadmin upload as a user"
}
function version() {
echo "$prog_name $prog_ver"
}
function check_deps() {
for i in date jq curl; do
(which $i &>/dev/null) && echo "OK: found $i" || echo "ERROR: $i not found"
done
if [[ ! $macos == "true" ]]; then
(which notify-send &>/dev/null) && echo "OK: found notify-send " || echo "ERROR: notify-send not found"
fi
if [[ $wayland == "true" ]]; then
for i in grim slurp; do
(which $i &>/dev/null) && echo "OK: found $i" || echo "ERROR: $i not found"
done
(which wl-copy &>/dev/null) && echo "OK: found wl-clipboard" || echo "ERROR: wl-clipboard not found"
elif [[ ! $macos == "true" ]]; then
(which escrotum &>/dev/null) && echo "OK: escrotum found (sidenote: you need it through python2, and you need to install pygtk)" || echo "ERROR: escrotum not found"
(which xclip &>/dev/null) && echo "OK: found xclip" || echo "ERROR: xclip not found"
fi
}
function take_screenshot() {
if [[ $1 == "area" ]]; then
if [[ $wayland == "true" ]]; then
grim -g "$(slurp)" "${2}"
elif [[ $macos == "true" ]]; then
screencapture -i "${2}"
else
escrotum -s "${2}"
fi
else
if [[ $wayland == "true" ]]; then
grim "${2}"
elif [[ $macos == "true" ]]; then
screencapture "${2}"
else
escrotum "${2}"
fi
fi
}
function upload_file_and_notify() {
response=$(curl --compressed --connect-timeout ${upload_connect_timeout} -m ${upload_timeout} --retry ${upload_retries} -H "Authorization: ${apikey}" -F upload=@"${1}" "${apiurl}/upload${is_admin}" | jq .url -r | tr -d '\n')
if [[ -n "${response}" ]]; then
if [[ $wayland == "true" ]]; then
echo -en "${response}" | wl-copy
elif [[ $macos == "true" ]]; then
echo -en "${response}" | pbcopy
else
echo -en "${response}" | xclip -selection clipboard
fi
if [[ $macos == "true" ]]; then
osascript -e "display notification \"${response}\" with title \"Success!\""
else
notify-send -t 5000 "Success!" "${response}" -i "${1}" --hint=int:transient:1
fi
else
if [[ $macos == "true" ]]; then
osascript -e "display notification \"Error uploading file\" with title \"Error!\""
else
notify-send -t 5000 "Error!" --hint=int:transient:1
fi
fi
}
while [[ $# != 0 ]]; do
case "${1}" in
--help | -h)
usage "${0}"
exit 0 ;;
--version | -v)
version "${0}"
exit 0 ;;
--check)
check_deps
exit 0 ;;
--area | -a)
mode=area
shift ;;
--full | -f)
mode=full
shift ;;
--keep | -k)
keep=true
shift ;;
--wayland | -w)
wayland=true
shift ;;
--xorg | -x)
wayland=false
shift ;;
--macos | -m)
macos=true
shift ;;
--admin)
is_admin="?admin=true"
shift ;;
--noadmin)
is_admin=""
shift ;;
*)
file_provided=true
file="${1}"
shift ;;
esac
done
if [[ -z $file ]]; then
file="${filename_format}"
fi
if [[ -z $file_provided ]]; then
take_screenshot $mode "${file}"
fi
upload_file_and_notify "${file}"
if [[ -z $file_provided && -z $keep ]]; then
rm -f "${file}"
fi

View file

@ -0,0 +1,11 @@
#!/bin/sh
pkill -9 pipewire
pkill -9 pipewire-pulse
pkill -9 vmware-user-suid-wrapper
pkill -9 xmousepasteblock
pipewire &
pipewire-pulse &
vmware-user-suid-wrapper &
xmousepasteblock &

37
linux/.local/bin/screenie Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
# screenie - capture a screenshot and use elixiremanager to send to
# elixi.re. uses flameshot as a drop-in replacement for kshare's "editing
# before sending" mechanic
# based off lynnesbian's sshotr.sh,
# https://gist.github.com/Lynnesbian/203e2a90a312cd02880f8e5762c01797
# this:
# - uses ~/Screenshots as a folder to store them all
# - requires notify-send, elixiremanager.sh requires it as well, so.
# - uses flameshot, more @ https://github.com/lupoDharkael/flameshot
# - On latest versions of flameshot, the Return key has been changed. You
# want to set the return key to copy image, rather than upload to imgur.
# - NOTE: press enter after doing a screenshot, instead of saving, for all
# of this to work
# change this if wanted
screenshot_folder="$HOME/Screenshots"
# set this to the path for elixiremanager.sh
elixiremanager="$HOME/.local/bin/elixiremanager.sh"
mkdir -p "$screenshot_folder"
date_str=$(date +'%Y-%m-%d-%H_%M_%S')
target="$screenshot_folder/screenie-$date_str.png"
maim -s "$target"
if [ ! -f "$target" ]; then
notify-send -t 5000 "screenshot not found, skipping sending"
else
notify-send -t 5000 "screenie: sending: $target"
source ~/.secrets
$elixiremanager "$target"
fi