1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00

Cleaned up shell scripts

This commit is contained in:
Ryan Kes 2020-02-22 20:40:41 +01:00
parent a4ca365978
commit 6bd89a8715
15 changed files with 96 additions and 122 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env fish
#Backup original #Backup original
cp config.h config.h.bak cp config.h config.h.bak

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env fish
# Build # Build
rm -rf src rm -rf src

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env fish
khal list khal list
read -s -n 1 read -s -n 1

View File

@ -1,4 +1,7 @@
#!/bin/sh #!/usr/bin/env sh
. ~/.cache/wal/colors.sh
# A dmenu binary prompt script. # A dmenu binary prompt script.
# Gives a dmenu prompt labeled with $1 to perform command $2. # Gives a dmenu prompt labeled with $1 to perform command $2.
# For example: # For example:

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env sh
### ###
# Switch wireguard vpns up/down # Switch wireguard vpns up/down

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/usr/bin/env sh
betterlockscreen -l blur -t "Step away from the machine!" betterlockscreen -l blur -t "Step away from the machine!"

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env sh
TIMESTAMP=$(date '+%Y-%m-%d-%H%M%S') TIMESTAMP=$(date '+%Y-%m-%d-%H%M%S')

View File

@ -1,2 +0,0 @@
#!/usr/bin/sh
st -c scratchpad

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env sh
xrandr --newmode "2560x1440_40" 201.00 2560 2720 2984 3408 1440 1443 1448 1476 -hsync +vsync xrandr --newmode "2560x1440_40" 201.00 2560 2720 2984 3408 1440 1443 1448 1476 -hsync +vsync
xrandr --addmode HDMI-2 2560x1440_40 xrandr --addmode HDMI-2 2560x1440_40

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Load wal colours # Load wal colours
. ~/.cache/wal/colors.sh . ~/.cache/wal/colors.sh

View File

@ -1,5 +1,4 @@
#!/bin/sh #!/usr/bin/env sh
# Helps open a file with xdg-open from mutt in a external program without weird side effects. # Helps open a file with xdg-open from mutt in a external program without weird side effects.
opener="setsid xdg-open" opener="setsid xdg-open"
$opener "$1" >/dev/null 2>&1 & $opener "$1" >/dev/null 2>&1 &

View File

@ -1,28 +1,12 @@
#!/bin/sh #!/usr/bin/fish
# Feed script a url or file location. switch $argv[1]
# If an image, it will view in sxiv, case '**.mkv' '**.webm' '**.mp4' '**youtube.com**' '**youtu.be**' '**hooktube.com**' '**bitchute.com**' '**lbry.tv**' '**.mp3' '**.flac'
# if a video or gif, it will view in mpv setsid mpv --input-ipc-server=/tmp/mpvsoc"(date +%s)" -quiet "$argv[1]" >/dev/null 2>&1 &
# if a music file or pdf, it will download, case '*'
# otherwise it opens link in browser. if [ -f $argv[1] ]
"$TERMINAL" -e "$EDITOR $argv[1]"
export BROWSER="brave"
# Set default terminal
export TERMINAL="alacritty"
case "$1" in
*mkv|*webm|*mp4|*youtube.com*|*youtu.be*|*hooktube.com*|*bitchute.com*)
setsid mpv --input-ipc-server=/tmp/mpvsoc"$(date +%s)" -quiet "$1" >/dev/null 2>&1 & ;;
*png|*jpg|*jpe|*jpeg|*gif)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
*mp3|*flac|*opus|*mp3?source*)
setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
*)
if [ -f "$1" ];
then
"$TERMINAL" -e "$EDITOR $1"
else else
setsid "$BROWSER" "$1" >/dev/null 2>&1 & setsid "$BROWSER" "$argv[1]" >/dev/null 2>&1 &
fi ;; end
esac end

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
readonly ID_PREVIEW="preview" readonly ID_PREVIEW="preview"
#PLAY_GIF="yes" #PLAY_GIF="yes"
@ -13,14 +13,14 @@ readonly ID_PREVIEW="preview"
if [ -e "$FIFO_UEBERZUG" ]; then if [ -e "$FIFO_UEBERZUG" ]; then
if [[ "$1" == "draw" ]]; then if [[ "$1" == "draw" ]]; then
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \ [x]="$2" [y]="$3" [width]="$4" [height]="$5"
[path]="$PWD/$6") \ [path]="$PWD/$6") \
>"$FIFO_UEBERZUG" >"$FIFO_UEBERZUG"
elif [[ "$1" == "videopreview" ]]; then elif [[ "$1" == "videopreview" ]]; then
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/" [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
[[ ! -f "/tmp$PWD/$6.png" ]] && ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10 [[ ! -f "/tmp$PWD/$6.png" ]] && ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \ [x]="$2" [y]="$3" [width]="$4" [height]="$5"
[path]="/tmp$PWD/$6.png") \ [path]="/tmp$PWD/$6.png") \
>"$FIFO_UEBERZUG" >"$FIFO_UEBERZUG"
elif [[ "$1" == "gifpreview" ]]; then elif [[ "$1" == "gifpreview" ]]; then
@ -28,7 +28,7 @@ if [ -e "$FIFO_UEBERZUG" ]; then
if [[ ! -z "$PLAY_GIF" ]]; then if [[ ! -z "$PLAY_GIF" ]]; then
for frame in $(ls -1 /tmp$PWD/$6/$6*.png | sort -V); do for frame in $(ls -1 /tmp$PWD/$6/$6*.png | sort -V); do
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \ [x]="$2" [y]="$3" [width]="$4" [height]="$5"
[path]="$frame") \ [path]="$frame") \
>"$FIFO_UEBERZUG" >"$FIFO_UEBERZUG"
# Sleep between frames to make the animation smooth. # Sleep between frames to make the animation smooth.
@ -36,7 +36,7 @@ if [ -e "$FIFO_UEBERZUG" ]; then
done done
else else
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \ [x]="$2" [y]="$3" [width]="$4" [height]="$5"
[path]="/tmp$PWD/$6/$6-0.png") \ [path]="/tmp$PWD/$6/$6-0.png") \
>"$FIFO_UEBERZUG" >"$FIFO_UEBERZUG"
fi fi
@ -44,14 +44,14 @@ if [ -e "$FIFO_UEBERZUG" ]; then
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/" [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
[[ ! -f "/tmp$PWD/$6.png" ]] && epub-thumbnailer "$6" "/tmp$PWD/$6.png" 512 [[ ! -f "/tmp$PWD/$6.png" ]] && epub-thumbnailer "$6" "/tmp$PWD/$6.png" 512
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \ [x]="$2" [y]="$3" [width]="$4" [height]="$5"
[path]="/tmp$PWD/$6.png") \ [path]="/tmp$PWD/$6.png") \
>"$FIFO_UEBERZUG" >"$FIFO_UEBERZUG"
elif [[ "$1" == "pdfpreview" ]]; then elif [[ "$1" == "pdfpreview" ]]; then
[[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/" [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
[[ ! -f "/tmp$PWD/$6.png" ]] && pdftoppm -png -singlefile "$6" "/tmp$PWD/$6" [[ ! -f "/tmp$PWD/$6.png" ]] && pdftoppm -png -singlefile "$6" "/tmp$PWD/$6"
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
[x]="$2" [y]="$3" [width]="$4" [height]="$5" \ [x]="$2" [y]="$3" [width]="$4" [height]="$5"
[path]="/tmp$PWD/$6.png") \ [path]="/tmp$PWD/$6.png") \
>"$FIFO_UEBERZUG" >"$FIFO_UEBERZUG"
elif [[ "$1" == "clear" ]]; then elif [[ "$1" == "clear" ]]; then

View File

@ -1,13 +1,3 @@
#!/bin/sh #!/usr/bin/env sh
clear betterlockscreen -u $1
WIDTH=$(xrandr | grep '\*' | awk -F 'x' '{print $1}' | sed 's/ //g')
OUTPUT_IMAGE="$HOME/.cache/lock.png"
echo "Converting ${1} to ${OUTPUT_IMAGE}...."
convert "${1}" "${OUTPUT_IMAGE}"
echo "done!"
echo "Reszing ${OUTPUT_IMAGE} to width ${WIDTH}...."
convert "${OUTPUT_IMAGE}" -resize "${WIDTH}"x "${OUTPUT_IMAGE}"
echo "done!"

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env sh
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}" export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
function cleanup { function cleanup() {
rm "$FIFO_UEBERZUG" 2>/dev/null rm "$FIFO_UEBERZUG" 2>/dev/null
pkill -P $$ 2>/dev/null pkill -P $$ 2>/dev/null
} }