AutoYADM commit: 2025-01-22 13:45:06

This commit is contained in:
Daniel Fichtinger 2025-01-22 13:45:06 -05:00
parent e0a4daea1f
commit 5e452a1408

View file

@ -1,5 +1,5 @@
#!/bin/bash
WL_PRESENT_DMENU="tofi"
usage() {
echo "usage: wl-present [options] <command> [argument]"
echo
@ -80,11 +80,15 @@ pipectl-shim() {
opt="$1"
shift
case "$opt" in
-n|--name) arg="$1"; shift; PIPENAME="pipectl.$(id -u).$arg.pipe";;
-i|--in) MODE=in;;
-o|--out) MODE=out;;
-f|--force) FORCE=1;;
--) break;;
-n | --name)
arg="$1"
shift
PIPENAME="pipectl.$(id -u).$arg.pipe"
;;
-i | --in) MODE=in ;;
-o | --out) MODE=out ;;
-f | --force) FORCE=1 ;;
--) break ;;
esac
done
@ -95,15 +99,21 @@ pipectl-shim() {
echo "error: could not open pipe at '$PIPE': No such file or directory" >&2
return 1
else
cat > "$PIPE"
fi;;
cat >"$PIPE"
fi ;;
"out") if [[ "$FORCE" -eq 0 && -p "$PIPE" ]]; then
echo "error: cannot create pipe at '$PIPE': File exists" >&2
return 1
else
[[ "$FORCE" -eq 1 ]] && rm -f "$PIPE"
mkfifo "$PIPE"; (tail -f "$PIPE" & echo > "$PIPE"; wait); rm -f "$PIPE"
fi;;
mkfifo "$PIPE"
(
tail -f "$PIPE" &
echo >"$PIPE"
wait
)
rm -f "$PIPE"
fi ;;
esac
}
@ -122,7 +132,7 @@ slurp-output-or-region() {
mirror() {
if [[ "$#" -eq 0 || "$1" =~ ^- ]]; then
OUTPUT_REGION=$(ask-output-or-region)
IFS='|' read -r OUTPUT REGION <<< "$OUTPUT_REGION"
IFS='|' read -r OUTPUT REGION <<<"$OUTPUT_REGION"
mirror "$OUTPUT" -r "$REGION" "$@"
return
@ -135,7 +145,7 @@ mirror() {
}
mirror-cmd() {
$PIPECTL -n "$PRESENT_PIPE_NAME" -i <<< "$1"
$PIPECTL -n "$PRESENT_PIPE_NAME" -i <<<"$1"
}
set-output() {
@ -170,7 +180,13 @@ ask-output-or-region() {
}
ask-scaling() {
(echo fit; echo cover; echo exact; echo linear; echo nearest) | $DMENU -p "wl-present scaling"
(
echo fit
echo cover
echo exact
echo linear
echo nearest
) | $DMENU -p "wl-present scaling"
[[ $? -ne 0 ]] && exit 1
}
@ -206,9 +222,13 @@ while [[ $# -gt 0 && "${1:0:1}" == "-" ]]; do
opt="$1"
shift
case "$opt" in
-n|--name) arg="$1"; shift; PRESENT_PIPE_NAME="$arg";;
-h|--help) usage;;
--) break;;
-n | --name)
arg="$1"
shift
PRESENT_PIPE_NAME="$arg"
;;
-h | --help) usage ;;
--) break ;;
esac
done
@ -217,19 +237,22 @@ if [[ $# -eq 0 ]]; then
fi
case "$1" in
help) usage;;
mirror) shift; mirror "$@";;
set-output) set-output "${2:-$(ask-output)}";;
set-region) set-region "${2:-$(ask-region)}";;
unset-region|no-region) mirror-cmd --no-region;;
set-scaling) set-scaling "${2:-$(ask-scaling)}";;
freeze) mirror-cmd --freeze;;
unfreeze) mirror-cmd --unfreeze;;
toggle-freeze) mirror-cmd --toggle-freeze;;
fullscreen) mirror-cmd --fullscreen;;
unfullscreen|no-fullscreen) mirror-cmd --no-fullscreen;;
fullscreen-output) set-fullscreen-output "${2:-$(ask-output)}";;
no-fullscreen-output) mirror-cmd --no-fullscreen-output;;
custom) mirror-cmd "${2:-$(ask-custom)}";;
*) usage;;
help) usage ;;
mirror)
shift
mirror "$@"
;;
set-output) set-output "${2:-$(ask-output)}" ;;
set-region) set-region "${2:-$(ask-region)}" ;;
unset-region | no-region) mirror-cmd --no-region ;;
set-scaling) set-scaling "${2:-$(ask-scaling)}" ;;
freeze) mirror-cmd --freeze ;;
unfreeze) mirror-cmd --unfreeze ;;
toggle-freeze) mirror-cmd --toggle-freeze ;;
fullscreen) mirror-cmd --fullscreen ;;
unfullscreen | no-fullscreen) mirror-cmd --no-fullscreen ;;
fullscreen-output) set-fullscreen-output "${2:-$(ask-output)}" ;;
no-fullscreen-output) mirror-cmd --no-fullscreen-output ;;
custom) mirror-cmd "${2:-$(ask-custom)}" ;;
*) usage ;;
esac