updated scripts to pass shellcheck, mostly

This commit is contained in:
Solomon Laing 2023-02-14 12:31:39 +10:30
parent cf18461c24
commit 7bc48e0a0d
47 changed files with 327 additions and 431 deletions

View File

@ -26,7 +26,7 @@ return {
"rcarriga/nvim-notify",
opts = {
-- Animation style (see below for details)
stages = "fade_in_slide_out",
stages = "static",
-- Render function for notifications. See notify-render()
render = "default",

View File

@ -1,12 +1,12 @@
#!/bin/bash
[[ "$(upower -i $(upower -e | grep 'BAT'))" == "" ]] && exit
[[ "$(upower -i "$(upower -e | grep 'BAT')")" == "" ]] && exit
current=$(upower -i $(upower -e | grep 'BAT') | grep -E "percentage" | sed 's/.*://' | sed 's/ *//')
state=$(upower -i $(upower -e | grep 'BAT') | grep -E "state" | sed 's/.*://' | sed 's/ *//')
current=$(upower -i "$(upower -e | grep 'BAT')" | grep -E "percentage" | sed 's/.*://' | sed 's/ *//')
state=$(upower -i "$(upower -e | grep 'BAT')" | grep -E "state" | sed 's/.*://' | sed 's/ *//')
if [[ "$state" == "not charging" ]]; then
state="full"
state="full"
fi
echo "$current $state"

View File

@ -1,22 +1,22 @@
#!/bin/bash
if git status &>/dev/null; then
branch=$(git branch --show-current)
branch=$(git branch --show-current)
if [ -z "$branch" ]; then
echo "(detached)"
exit 0
fi
if [ -z "$branch" ]; then
echo "(detached)"
exit 0
fi
read -ra counts <<< "$(git rev-list --left-right --count "$branch"...origin/"$branch")"
to_push=${counts[0]}
to_pull=${counts[1]}
read -ra counts <<< "$(git rev-list --left-right --count "$branch"...origin/"$branch")"
to_push=${counts[0]}
to_pull=${counts[1]}
extras=$([[ ${counts[0]} -eq 0 && ${counts[1]} -eq 0 ]] || echo " $to_push↑ $to_pull↓")
extras=$([[ ${counts[0]} -eq 0 && ${counts[1]} -eq 0 ]] || echo " $to_push↑ $to_pull↓")
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
echo "($branch*$extras)"
else
echo "($branch~$extras)"
fi
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
echo "($branch*$extras)"
else
echo "($branch~$extras)"
fi
fi

View File

@ -1,17 +0,0 @@
#!/bin/sh
# Syncs repositories and downloads updates, meant to be run as a cronjob.
notify-send "📦 Repository Sync" "Checking for package updates..."
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]"
then
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
else
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
fi

View File

@ -9,7 +9,7 @@ if [[ -z $selected ]]; then
exit 0
fi
read -p "Enter Query: " query
read -rp "Enter Query: " query
if grep -qs "$selected" "$languages"; then
query=$(echo "$query" | tr ' ' '+')

View File

@ -17,43 +17,43 @@ ext="${file##*.}"
cd "$dir" || exit 1
textype() { \
textarget="$(getcomproot "$file" || echo "$file")"
echo "$textarget"
command="pdflatex"
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
$command --output-directory="${textarget%/*}" "${textarget%.*}"
grep -qi addbibresource "$textarget" &&
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}"
textarget="$(getcomproot "$file" || echo "$file")"
echo "$textarget"
command="pdflatex"
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
$command --output-directory="${textarget%/*}" "${textarget%.*}"
grep -qi addbibresource "$textarget" &&
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}" &&
$command --output-directory="${textarget%/*}" "${textarget%.*}"
}
case "$ext" in
# Try to keep these cases in alphabetical order.
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
c) cc "$file" -o "$base" && "$base" ;;
cpp) g++ "$file" -o "$base" && "$base" ;;
cs) mcs "$file" && mono "$base".exe ;;
go) go run "$file" ;;
h) sudo make install ;;
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff -T pdf > "$base".pdf
else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;;
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;;
sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
# Try to keep these cases in alphabetical order.
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
c) cc "$file" -o "$base" && "$base" ;;
cpp) g++ "$file" -o "$base" && "$base" ;;
cs) mcs "$file" && mono "$base".exe ;;
go) go run "$file" ;;
h) sudo make install ;;
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
m) octave "$file" ;;
md) if [ -x "$(command -v lowdown)" ]; then
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
elif [ -x "$(command -v groffdown)" ]; then
groffdown -i "$file" | groff -T pdf > "$base".pdf
else
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
fi ; ;;
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
py) python "$file" ;;
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
rs) cargo build ;;
sass) sassc -a "$file" "$base".css ;;
scad) openscad -o "$base".stl "$file" ;;
sent) setsid -f sent "$file" 2>/dev/null ;;
tex) textype "$file" ;;
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
esac

View File

@ -2,16 +2,15 @@
# Syncs repositories and downloads updates, meant to be run as a cronjob.
notify-send "📦 Repository Sync" "Checking for package updates..."
notify-send "Repository Sync" "Checking for package updates..."
sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates.
Check your internet connection, if pacman is already running, or run update manually to see errors."
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
if pacman -Qu | grep -v "\[ignored\]"
then
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
notify-send "Repository Sync" "Sync comelete. You have updates $(pacman -Qu | grep -vc "\[ignored\]") available."
else
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
notify-send "Repository Sync" "Sync complete. No new packages for update."
fi

View File

@ -3,4 +3,4 @@
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/cronsaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "Cronjobs saved and disabled.")

View File

@ -1,6 +0,0 @@
#!/bin/sh
# Toggles all cronjobs off/on.
# Stores disabled crontabs in ~/.config/cronsaved until restored.
([ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved ] && crontab - < "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && rm "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && notify-send "🕓 Cronjobs re-enabled.") || ( crontab -l > "${XDG_CONFIG_HOME:-$HOME/.config}"/cronsaved && crontab -r && notify-send "🕓 Cronjobs saved and disabled.")

View File

@ -1,11 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-sink
default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then
set-default-sink
fi
default=$(cat $default_loc)
default="$(<"$default_loc")"
pactl set-sink-volume $default -5%
pactl set-sink-volume "$default" -5%

View File

@ -1,11 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-source
default_loc="$HOME/.cache/pactl-default-source"
if [ ! -f "$default_loc" ] ; then
set-default-source
fi
default=$(cat $default_loc)
default="$(<"$default_loc")"
pactl set-source-volume $default -5%
pactl set-source-volume "$default" -5%

View File

@ -36,31 +36,31 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
fi
}
}
morescreen() { # If multi-monitor is selected and there are more than two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
}
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
}
multimon() { # Multi-monitor handler.
case "$(echo "$screens" | wc -l)" in
2) twoscreen ;;
*) morescreen ;;
esac ;}
case "$(echo "$screens" | wc -l)" in
2) twoscreen ;;
*) morescreen ;;
esac ;}
onescreen() { # If only one output available or chosen.
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
}
xrandr --output "$1" --auto --scale 1.0x1.0 "$(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)"
}
postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed.
remaps # Re-remap keys if keyboard added (for laptop bases)
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
}
setbg # Fix background if screen size/arangement has changed.
remaps # Re-remap keys if keyboard added (for laptop bases)
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
}
# Get all possible displays
allposs=$(xrandr -q | grep "connected")
@ -70,14 +70,14 @@ screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
# Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in
"manual selection") arandr ; exit ;;
"multi-monitor") multimon ;;
*) onescreen "$chosen" ;;
"manual selection") arandr ; exit ;;
"multi-monitor") multimon ;;
*) onescreen "$chosen" ;;
esac
postrun

View File

@ -6,62 +6,62 @@
# input a novel directory, it will prompt you to create that directory.
getmount() { \
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
test -z "$mp" && exit 1
if [ ! -d "$mp" ]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
fi
}
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
test -z "$mp" && exit 1
if [ ! -d "$mp" ]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
fi
}
mountusb() { \
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
partitiontype="$(lsblk -no "fstype" "$chosen")"
case "$partitiontype" in
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)";;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
esac && notify-send "💻 USB mounting" "$chosen mounted to $mp." ||
notify-send "💻 Drive failed to mount." "Probably a permissions issue or drive is already mounted."
}
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
sudo -A mount "$chosen" 2>/dev/null && notify-send "USB mounting" "$chosen mounted." && exit 0
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
partitiontype="$(lsblk -no "fstype" "$chosen")"
case "$partitiontype" in
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000 ;;
"exfat") sudo -A mount "$chosen" "$mp" -o uid="$(id -u)",gid="$(id -g)" ;;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp" ;;
esac && notify-send "USB mounting" "$chosen mounted to $mp." ||
notify-send "Drive failed to mount." "Probably a permissions issue or drive is already mounted."
}
mountandroid() { \
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d"
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
simple-mtpfs --device "$chosen" "$mp" &&
notify-send "🤖 Android Mounting" "Android device mounted to $mp." ||
notify-send "🤖 Android failed mounting." "Probably a permissions issue or phone is already mounted."
}
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d"
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
simple-mtpfs --device "$chosen" "$mp" &&
notify-send "Android Mounting" "Android device mounted to $mp." ||
notify-send "Android failed mounting." "Probably a permissions issue or phone is already mounted."
}
asktype() { \
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
case $choice in
USB) mountusb ;;
Android) mountandroid ;;
esac
}
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
case $choice in
USB) mountusb ;;
Android) mountandroid ;;
esac
}
anddrives=$(simple-mtpfs -l 2>/dev/null)
usbdrives="$(lsblk -rpo "name,type,size,label,mountpoint,fstype" | grep -v crypto_LUKS | grep 'part\|rom' | sed 's/ /:/g' | awk -F':' '$5==""{printf "%s (%s) %s\n",$1,$3,$4}')"
if [ -z "$usbdrives" ]; then
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
echo "Android device(s) detected."
mountandroid
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
echo "Android device(s) detected."
mountandroid
else
if [ -z "$anddrives" ]; then
echo "USB drive(s) detected."
mountusb
else
echo "Mountable USB drive(s) and Android device(s) detected."
asktype
fi
if [ -z "$anddrives" ]; then
echo "USB drive(s) detected."
mountusb
else
echo "Mountable USB drive(s) and Android device(s) detected."
asktype
fi
fi

View File

@ -8,14 +8,14 @@
# Taken shamelessly from Luke Smith
if [ -n "$3" ]
if [[ -n "$3" ]]
then
choice=$(echo -e "Yes\nNo" | dmenu -bw 0 -i -p "$1")
else
choice=$(echo -e "No\nYes" | dmenu -bw 0 -i -p "$1")
fi
if [ $choice = "Yes" ]
if [[ "$choice" = "Yes" ]]
then
$2
fi

View File

@ -4,7 +4,7 @@
# Description: Search various search engines (inspired by surfraw).
# Dependencies: dmenu and a web browser
# Usage: dmenusearch <engine>
# where engine is amazon, duckduckgo, etc.
# where engine is amazon, duckduckgo, etc.
# without engine all options will be listed
# Pilfered from Derek Taylor @ https://www.gitlab.com/dwt1/dmscripts
@ -88,4 +88,4 @@ while [ -z "$query" ]; do
done
# Display search results in web browser
$DMBROWSER "$url""$query"
$DMBROWSER "$url" "$query"

View File

@ -9,13 +9,13 @@ drives="$(lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,"
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
case "$chosen" in
📱*)
chosen="${chosen#📱 }"
sudo -A umount -l "$chosen"
;;
*)
chosen="${chosen% (*}"
sudo -A umount -l "$chosen"
;;
esac && notify-send "🖥️ Drive unmounted." "$chosen successfully unmounted." ||
notify-send "🖥️ Drive failed to unmount." "Possibly a permissions or I/O issue."
📱*)
chosen="${chosen#📱 }"
sudo -A umount -l "$chosen"
;;
*)
chosen="${chosen% (*}"
sudo -A umount -l "$chosen"
;;
esac && notify-send "Drive unmounted." "$chosen successfully unmounted." ||
notify-send "Drive failed to unmount." "Possibly a permissions or I/O issue."

View File

@ -7,39 +7,39 @@
# Behavior with `-c` option: Extract contents into current directory
while getopts "hc" o; do case "${o}" in
c) extracthere="True" ;;
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;;
c) extracthere="True" ;;
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;;
esac done
if [ -z "$extracthere" ]; then
archive="$(readlink -f "$*")" &&
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
mkdir -p "$directory" &&
cd "$directory" || exit 1
archive="$(readlink -f "$*")" &&
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
mkdir -p "$directory" &&
cd "$directory" || exit 1
else
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)"
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)"
fi
[ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1
if [ -f "$archive" ] ; then
case "$archive" in
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
*.tar.xz) tar -xf "$archive" ;;
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
*.tar.zst) tar -I zstd -xf "$archive" ;;
*.lzma) unlzma "$archive" ;;
*.bz2) bunzip2 "$archive" ;;
*.rar) unrar x -ad "$archive" ;;
*.gz) gunzip "$archive" ;;
*.tar) tar xvf "$archive" ;;
*.zip) unzip "$archive" ;;
*.Z) uncompress "$archive" ;;
*.7z) 7z x "$archive" ;;
*.xz) unxz "$archive" ;;
*.exe) cabextract "$archive" ;;
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
esac
case "$archive" in
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
*.tar.xz) tar -xf "$archive" ;;
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
*.tar.zst) tar -I zstd -xf "$archive" ;;
*.lzma) unlzma "$archive" ;;
*.bz2) bunzip2 "$archive" ;;
*.rar) unrar x -ad "$archive" ;;
*.gz) gunzip "$archive" ;;
*.tar) tar xvf "$archive" ;;
*.zip) unzip "$archive" ;;
*.Z) uncompress "$archive" ;;
*.7z) 7z x "$archive" ;;
*.xz) unxz "$archive" ;;
*.exe) cabextract "$archive" ;;
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
esac
else
printf "File \"%s\" not found.\\n" "$archive"
printf "File \"%s\" not found.\\n" "$archive"
fi

View File

@ -1,11 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-sink
default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then
set-default-sink
fi
default=$(cat $default_loc)
default=$(<"$default_loc")
pactl set-sink-volume $default +5%
pactl set-sink-volume "$default" +5%

View File

@ -1,11 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-source
default_loc="$HOME/.cache/pactl-default-source"
if [ ! -f "$default_loc" ] ; then
set-default-source
fi
default=$(cat $default_loc)
default=$(<"$default_loc")
pactl set-source-volume $default +5%
pactl set-source-volume "$default" +5%

View File

@ -1,8 +0,0 @@
#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
echo "IOMMU Group ${g##*/}:"
for d in $g/devices/*; do
echo -e "\t$(lspci -nns ${d##*/})"
done;
done;

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
fn="/tmp/kbswitcher.status"
fn="$HOME/.cache/kbswitcher-status"
layout=""
@ -13,11 +13,11 @@ else
us)
echo "dvorak" > "$fn"
layout="dvorak"
;;
;;
dvorak)
echo "us" > "$fn"
layout="us"
;;
;;
esac
fi

View File

@ -1,19 +1,19 @@
#!/bin/bash
if command -v brillo &> /dev/null; then
function send_notification() {
brightness=$(printf "%.0f\n" $(brillo -G))
dunstify -a "changebrightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness%" -t 2000
}
function send_notification() {
brightness=$(printf "%.0f\n" "$(brillo -G)")
dunstify -a "changebrightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness%" -t 2000
}
case $1 in
up)
brillo -A 5 -q -u 150000
send_notification $1
;;
down)
brillo -U 5 -q -u 150000
send_notification $1
;;
esac
case $1 in
up)
brillo -A 5 -q -u 150000
send_notification "$1"
;;
down)
brillo -U 5 -q -u 150000
send_notification "$1"
;;
esac
fi

View File

@ -1,7 +1,8 @@
#!/bin/sh
#!/bin/bash
if [[ -x "$1" ]]; then
$1
else
echo "$1 does not exist or couldn't be executed."
if [[ ! -x "$1" ]]; then
echo "$1 does not exist or couldn't be executed."
exit 1
fi
$1

View File

@ -1,16 +1,17 @@
#!/bin/bash
layouts=($(ls "$HOME/.screenlayout/"))
layouts=("$(ls "$HOME/.screenlayout/")")
add="add layout..."
layouts+=("$add")
choice=$( printf '%s\n' "${layouts[@]}" | dmenu -i -p 'Choose a screenlayout:') "$@" || exit
choice=$(printf '%s\n' "${layouts[@]}" | dmenu -i -p 'Choose a screenlayout:') || exit 0
if [ "$choice" = "$add" ]
then
arandr &
else
exec "$HOME/.screenlayout/$choice"
arandr &
exit 0
fi
exec "$HOME/.screenlayout/$choice"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/bash
SCRIPTNAME=$(basename $0)
SCRIPTNAME=$(basename "$0")
FILENAME="$HOME/$SCRIPTNAME-$(date +'%Y-%m-%d-%H-%M-%S').png"
case ${1:-} in
@ -9,5 +9,5 @@ case ${1:-} in
esac
maim --format=png $SEL "$FILENAME"
echo -n $FILENAME | xclip -selection clipbard
echo -n "$FILENAME" | xclip -selection clipbard
notify-send "Screenshot" "$(echo -e "Screen shot saved\n$FILENAME")"

View File

@ -6,8 +6,9 @@ if [ -z "$choice" ] ; then
exit 0;
fi
default_loc="$HOME/.cache/pactl-default-sink"
rm /tmp/pactl-default-sink --force # to ignore if it isn't there
touch /tmp/pactl-default-sink
echo "$choice" > /tmp/pactl-default-sink
pactl set-default-sink $choice # make sure that the chosen sink is the
rm "$default_loc" --force # to ignore if it isn't there
touch "$default_loc"
echo "$choice" > "$default_loc"
pactl set-default-sink "$choice" # make sure that the chosen sink is the

View File

@ -6,8 +6,9 @@ if [ -z "$choice" ] ; then
exit 0;
fi
default_loc="$HOME/.cache/pactl-default-source"
rm /tmp/pactl-default-source --force # to ignore if it isn't there
touch /tmp/pactl-default-source
echo "$choice" > /tmp/pactl-default-source
pactl set-default-source $choice # make sure that the chosen sink is the
rm "$default_loc" --force # to ignore if it isn't there
touch "$default_loc"
echo "$choice" > "$default_loc"
pactl set-default-source "$choice" # make sure that the chosen sink is the

View File

@ -1,13 +1,13 @@
#!/bin/bash
default_loc=/tmp/pactl-default-sink
default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then
set-default-sink
fi
default=$(cat $default_loc)
default=$(<"$default_loc")
value=$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?")
value=${1-$(echo -e "" | dmenu -bw 0 -i -p "Set vol to what?")}
pactl set-sink-volume $default $value%
pactl set-sink-volume "$default" "$value%"

View File

@ -2,43 +2,44 @@
icon=""
status=$(bash-status-bat)
parts=($status)
current=$(echo "${parts[0]}" | sed 's/\%//')
IFS=" " read -ra parts <<< "$(bash-status-bat)"
parts_0=${parts[0]}
current=${parts_0//\%/}
state=${parts[1]}
status="$current%"
if [[ "$state" == "discharging" ]]; then
case $(((current/20)+1)) in
1)
icon=" "
;;
2)
icon=" "
;;
3)
icon=" "
;;
4)
icon=" "
;;
5)
icon=" "
;;
esac
case $((current/20+1)) in
1)
icon=" "
;;
2)
icon=" "
;;
3)
icon=" "
;;
4)
icon=" "
;;
5)
icon=" "
;;
esac
fi
if [[ "$state" == "not-charging" ]]; then
icon=" "
fi
if [[ "$state" == "fully-charged" ]]; then
icon=" "
status="Full"
fi
if [[ "$state" == "charging" ]]; then
icon=" "
fi
case $state in
not-charging)
icon=" "
;;
fully-charged)
icon=" "
status="Full"
;;
charging)
icon=" "
;;
esac
echo "$icon $status"

View File

@ -3,8 +3,8 @@
freemb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4 }')
freegb=$(df -h -B 1048576 | grep "/$" | awk -F ' ' '{ print $4/1024 }')
if [ $freemb -lt 1024 ]; then
printf " %0.2fMb" $freemb
if [ "$freemb" -lt 1024 ]; then
printf " %0.2fMb" "$freemb"
else
printf " %0.2fGb" $freegb
printf " %0.2fGb" "$freegb"
fi

View File

@ -1,35 +1,15 @@
#!/bin/sh
#!/bin/bash
dev_wifi=$(cat "$HOME"/.config/net-cfg/dev_wifi)
dev_eth=$(cat "$HOME"/.config/net-cfg/dev_eth)
dev_vpn=$(cat "$HOME"/.config/net-cfg/dev_vpn)
dev_wifi=$(<"$HOME"/.config/net-cfg/dev_wifi)
dev_eth=$(<"$HOME"/.config/net-cfg/dev_eth)
dev_vpn=$(<"$HOME"/.config/net-cfg/dev_vpn)
base03=#002b36
base02=#073642
base01=#586e75
base00=#657b83
base0=#839496
base1=#93a1a1
base2=#eee8d5
base3=#fdf6e3
yellow=#b58900
orange=#cb4b16
red=#dc322f
magenta=#d33682
violet=#6c71c4
blue=#268bd2
cyan=#2aa198
green=#859900
std_color=$magenta
wifi_icon=" "
color=$std_color;
eth="$(ip -o address | grep -i "$dev_eth *inet ")"
if [ -n "$eth" ]
then
speed="$(cat /sys/class/net/$dev_eth/speed)"
speed="$(cat "/sys/class/net/$dev_eth/speed")"
case $speed in
10) speed="10Base-T" ;;
100) speed="100Base-T" ;;
@ -39,7 +19,7 @@ then
eth_status="  $speed"
fi
ssid="$(iw dev $dev_wifi link | grep -i SSID)"
ssid="$(iw dev "$dev_wifi" link | grep -i SSID)"
if [ -n "$ssid" ]
then
signal="$(awk '/^\s*w/ { print int($3 * 100 / 70) "%" }' /proc/net/wireless)"
@ -50,12 +30,8 @@ vpn="$(ip -o address | grep -i "$dev_vpn *inet ")"
if [ -n "$vpn" ]
then
vpn_status=""
color=$green
else
vpn_status=""
fi
echo "${vpn_status} $wifi_status$eth_status"
# vim: ft=sh:expandtab:ts=4:shiftwidth=4

View File

@ -8,20 +8,21 @@ vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
[ "$vol" != "${vol%\[MUTED\]}" ] && echo  && exit
vol="${vol#Volume: }"
split() {
# For ommiting the . without calling and external program.
IFS=$2
set -- $1
printf '%s' "$@"
# For ommiting the . without calling and external program.
IFS=$2
set -- $1
printf '%s' "$@"
}
vol="$(split "$vol" ".")"
vol="${vol##0}"
case 1 in
$((vol >= 70)) ) icon="" ;;
$((vol >= 30)) ) icon="" ;;
$((vol >= 1)) ) icon="" ;;
* ) echo  && exit ;;
$((vol >= 70)) ) icon="" ;;
$((vol >= 30)) ) icon="" ;;
$((vol >= 1)) ) icon="" ;;
* ) echo  && exit ;;
esac
echo "$icon $vol%"

View File

@ -1,13 +1,13 @@
#!/bin/bash
branch_name=$(basename $1)
branch_name=$(basename "$1")
session_name=$(tmux display-message -p "#S")
clean_name=$(echo $branch_name | tr "./" "__")
clean_name=$(echo "$branch_name" | tr "./" "__")
target="$session_name:$clean_name"
if ! tmux has-session -t $target 2> /dev/null; then
tmux neww -dn $clean_name
if ! tmux has-session -t "$target" 2> /dev/null; then
tmux neww -dn "$clean_name"
fi
shift
tmux send-keys -t $target "$*" Enter
tmux send-keys -t "$target" "$*" Enter

View File

@ -3,12 +3,9 @@
session="system"
# Check if the session exists, discarding output
# We can check $? for the exit status (zero for success, non-zero for failure)
tmux has-session -t $session 2>/dev/null
if [ $? != 0 ]; then
# Set up your session
tmux new-session -s "$session"
if command -v tmux has-session -t $session 2>/dev/null != 0; then
# Set up your session
tmux new-session -s "$session"
fi
# Attach to created session

View File

@ -1,11 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-sink
default_loc="$HOME/.cache/pactl-default-sink"
if [ ! -f "$default_loc" ] ; then
set-default-sink
fi
default=$(cat $default_loc)
default=$(cat "$default_loc")
pactl set-sink-mute $default toggle
pactl set-sink-mute "$default" toggle

View File

@ -1,11 +1,11 @@
#!/bin/bash
default_loc=/tmp/pactl-default-source
default_loc="$HOME/.cache/pactl-default-source"
if [ ! -f "$default_loc" ] ; then
set-default-source
fi
default=$(cat $default_loc)
default=$(cat "$default_loc")
pactl set-source-mute $default toggle
pactl set-source-mute "$default" toggle

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
test_path="/tmp/trayer.exists"
test_path="$HOME/.cache/trayer-exists"
if [ -f "$test_path" ]; then
echo "stopping trayer"

View File

@ -1,4 +1,4 @@
#!/bin/sh
cmd=$(command -v $1)
cmd=$(command -v "$1")
test -n "$cmd" && exec vi "$cmd"

View File

@ -1,9 +1,5 @@
#!/bin/bash
# a simple wrapper for inserting xmobar stuff
status=$(status-bat)
parts=($status)
IFS=" " read -r -a parts <<< "$(status-bat)"
echo "<fn=1>${parts[0]} </fn> ${parts[1]}"

View File

@ -1,7 +1,4 @@
#!/bin/bash
status=$(status-disk)
parts=($status)
IFS=" " read -r -a parts <<< "$(status-disk)"
echo "<fn=1>${parts[0]} </fn> ${parts[1]}"

View File

@ -3,30 +3,14 @@
stdlayout=us # standard layout takes "default" color
stdname=en-us # arbitrary, descriptive only
base03=#002b36
base02=#073642
base01=#586e75
base00=#657b83
base0=#839496
base1=#93a1a1
base2=#eee8d5
base3=#fdf6e3
yellow=#b58900
orange=#cb4b16
red=#dc322f
magenta=#d33682
violet=#6c71c4
blue=#268bd2
cyan=#2aa198
green=#859900
layout="$(xkb-switch)"
case $layout in
${stdlayout}) color=$green; icon=" "; name=$stdname ;; # f11c fa-keyboard-o
"${stdlayout}") color=$green; icon=" "; name=$stdname ;; # f11c fa-keyboard-o
*) color=$magenta; icon=""; name="dvorak" ;; # f11c fa-keyboard-o
esac
echo "<fc=$color><fn=1>$icon </fn> ${name}</fc>"
# vim: ft=sh:expandtab:ts=4:shiftwidth=4

View File

@ -1,24 +1,12 @@
#!/bin/sh
#!/bin/bash
dev_wifi=$(cat "$HOME"/.config/xmobar/dev_wifi)
dev_eth=$(cat "$HOME"/.config/xmobar/dev_eth)
dev_vpn=$(cat "$HOME"/.config/xmobar/dev_vpn)
# base03=#002b36
# base02=#073642
# base01=#586e75
# base00=#657b83
# base0=#839496
# base1=#93a1a1
# base2=#eee8d5
# base3=#fdf6e3
yellow=#b58900
# orange=#cb4b16
red=#dc322f
magenta=#d33682
# violet=#6c71c4
# blue=#268bd2
# cyan=#2aa198
green=#859900
# connectivity status
@ -82,6 +70,3 @@ else
fi
echo "<fc=$color>${vpn_status}<fn=1>$icon </fn>${connectivity##*full}$wifi_status$eth_status</fc>"
# vim: ft=sh:expandtab:ts=4:shiftwidth=4

View File

@ -1,6 +1,6 @@
#!/bin/sh
count=$(yay -Qu | wc -l)
count=$(pacman -Qu | wc -l)
icon=""
echo "<fn=1>$icon </fn> $count"

View File

@ -1,46 +1,33 @@
#!/bin/sh
base03=#002b36
base02=#073642
base01=#586e75
base00=#657b83
base0=#839496
base1=#93a1a1
base2=#eee8d5
base3=#fdf6e3
yellow=#b58900
orange=#cb4b16
red=#dc322f
magenta=#d33682
violet=#6c71c4
blue=#268bd2
cyan=#2aa198
green=#859900
color=$cyan
vol="$(pamixer --get-volume)"
if [ $(pamixer --get-mute) = true ]; then
vol=MUTE
color=$red
icon="" # fa-volume-off f026
if [ "$(pamixer --get-mute)" = true ]; then
vol=MUTE
color=$red
icon="" # fa-volume-off f026
echo "<fc=$color><fn=1>$icon </fn>$vol</fc>"
echo "<fc=$color><fn=1>$icon </fn>$vol</fc>"
fi
if [ "$vol" -gt "100" ]; then
icon=""
color=$orange
icon=""
color=$orange
elif [ "$vol" -gt "70" ]; then
icon=""
icon=""
elif [ "$vol" -gt "30" ]; then
icon=""
icon=""
elif [ "$vol" -gt "0" ]; then
icon=""
icon=""
else
vol=MUTE
color=$red
icon=""
vol=MUTE
color=$red
icon=""
fi
echo "<fc=$color><fn=1>$icon </fn>$vol</fc>"

View File

@ -1,15 +1,15 @@
#!/bin/sh
#!/bin/bash
# simple script to read weather from airport code and return it for display in xmobar
weather=$(weather-report $1 -m --no-cache -n | \
grep -e '\[' \
-e 'Temp' | \
sed -e 's/\[using result //' \
-e 's/,.*\]//' \
-e 's/Temp.*: //' \
-e 's/ C//' \
-e 's/ //')
weather=$(weather-report "$1" -m --no-cache -n | \
grep -e '\[' \
-e 'Temp' | \
sed -e 's/\[using result //' \
-e 's/,.*\]//' \
-e 's/Temp.*: //' \
-e 's/ C//' \
-e 's/ //')
readarray -t y <<< "$weather"
@ -19,18 +19,18 @@ color=""
if ((temp > 30))
then
color="#ff5555"
color="#ff5555"
elif ((temp > 25))
then
color="#ffb86c"
color="#ffb86c"
elif ((temp > 20))
then
color="#f1fa8c"
color="#f1fa8c"
elif ((temp > 10))
then
color="#50fa7b"
color="#50fa7b"
else
color="#8be9fd"
color="#8be9fd"
fi
echo -e "<fc=#ff79c6>$loc <fc=$color>$temp</fc>C</fc>"

View File

@ -40,8 +40,8 @@ width=$(xprop -name panel | grep 'program specified minimum size' | cut -d ' ' -
iconfile="/tmp/trayer-padding-${width}px.xpm"
# If the desired icon does not exist create it
if [ ! -f $iconfile ]; then
create_xpm_icon $width $iconfile
if [ ! -f "$iconfile" ]; then
create_xpm_icon "$width" "$iconfile"
fi
# Output the icon tag for xmobar

View File

@ -1,6 +1,6 @@
#!/bin/bash
sed -n '/--START_KEYS/,/--END_KEYS/p' $HOME/.xmonad/xmonad.hs | \
sed -n '/--START_KEYS/,/--END_KEYS/p' "$HOME/.xmonad/xmonad.hs" | \
grep -e ', ("' \
-e '\[ ("' \
-e '--NOTE' | \
@ -9,4 +9,4 @@ sed -n '/--START_KEYS/,/--END_KEYS/p' $HOME/.xmonad/xmonad.hs | \
-e 's/\[ (/(/' \
-e 's/--NOTE /\n/' \
-e 's/, / --> /' | \
yad --text-info --back=#121e32 --fore=#dfdfef --geometry=1200x800
yad --text-info --back=#121e32 --fore=#dfdfef --geometry=1200x800