Move .scripts -> .local/bin
This commit is contained in:
Executable
+146
@@ -0,0 +1,146 @@
|
||||
#!/bin/sh
|
||||
|
||||
depend() {
|
||||
pactree -u -d 1 "$1" | tail -n +2 | sort
|
||||
}
|
||||
|
||||
emacs() {
|
||||
# Create new frame (if there isnt one or no file is specified)
|
||||
if [ -z "$(pgrep -f emacsclient.*-c)" ] || [ "$1" = "" ]; then
|
||||
emacsclient -a '' -c "$@" > /dev/null 2>&1 &
|
||||
else
|
||||
emacsclient -a '' "$@" > /dev/null 2>&1 &
|
||||
fi
|
||||
}
|
||||
|
||||
# $1 = find, $2 = list, $3 = list separator
|
||||
in_list() {
|
||||
[ -z "$1" ] || [ -z "$2" ] && return 1
|
||||
if ! echo "$2" | awk -v m="^$1$" -v RS="${3:-' '}" '$0 ~ m { exit 1 }'; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
java_doc() {
|
||||
mkdir -p './doc';
|
||||
javadoc -d './doc' -- *.java
|
||||
}
|
||||
|
||||
java_run () {
|
||||
mkdir -p './out';
|
||||
javac -d './out' "$1.java";
|
||||
java -cp './out' "$1"
|
||||
}
|
||||
|
||||
mkcd() {
|
||||
mkdir -p "$1" && cd "$1" || exit
|
||||
}
|
||||
|
||||
# Search for packages, by name only
|
||||
pacman_search() {
|
||||
pacman -Ss "$1" --color=always | \
|
||||
awk -v m="$1" '{ if ($0 !~ /^\s/) { if ($1 ~ m) { print; }} else { print; }}'
|
||||
}
|
||||
|
||||
pastebin() {
|
||||
echo "$1" | curl -F 'f:1=<-' ix.io
|
||||
}
|
||||
|
||||
print_project() {
|
||||
tree -f --noreport | egrep -ve "vendor(\/.*){2}" -ve "build(\/.*)" | sed -E 's%\./.*/%%g; s%\./%%g;'
|
||||
}
|
||||
|
||||
raspbian() {
|
||||
sudo systemctl start avahi-daemon.service
|
||||
if ! ip a show usb0 | grep -q 'inet6'; then
|
||||
sudo dhcpcd usb0
|
||||
fi
|
||||
ssh -6 pi@"$(avahi-resolve-host-name raspberrypi.local | awk '{ print $2 }')"%usb0
|
||||
sudo systemctl stop avahi-daemon.service
|
||||
}
|
||||
|
||||
screencast() {
|
||||
IS_RUNNING="$(pgrep ffmpeg)"
|
||||
if [ "$IS_RUNNING" != "" ]; then
|
||||
notify-send "Stopped recording.."
|
||||
# Kill with SIGTERM, allowing finishing touches
|
||||
pkill -15 ffmpeg
|
||||
sleep 3
|
||||
# Kill with SIGKILL, just in case it is still running
|
||||
pkill -9 ffmpeg
|
||||
else
|
||||
NAME=${1:-"output"}
|
||||
[ -n "$2" ] && AUDIO_CODEC="-c:a aac"
|
||||
[ -n "$2" ] && AUDIO_SOURCE="-f pulse -ac 2 -i $2" # 1 = system, 2 = mic
|
||||
|
||||
notify-send "Started recording.."
|
||||
ffmpeg -y \
|
||||
-threads 8 \
|
||||
-f x11grab \
|
||||
-framerate 30 \
|
||||
-s 1280x720 \
|
||||
-i "$DISPLAY.0+640,180" \
|
||||
$AUDIO_SOURCE \
|
||||
-r 30 \
|
||||
$AUDIO_CODEC \
|
||||
-c:v libx264 -crf 0 -preset ultrafast \
|
||||
"$NAME.mkv" &
|
||||
fi
|
||||
}
|
||||
|
||||
stream() {
|
||||
QUALITY=${2:-"720p"}
|
||||
|
||||
streamlink --player mpv "https://twitch.tv/$1" "$QUALITY" > /dev/null 2>&1 &
|
||||
}
|
||||
|
||||
update_mirrorlist() {
|
||||
sudo rm /etc/pacman.d/mirrorlist.pacnew
|
||||
sudo reflector --latest 100 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
|
||||
}
|
||||
|
||||
webmconvert() {
|
||||
[ "$2" = "1" ] && AUDIO="-c:a libvorbis" || AUDIO="-an"
|
||||
|
||||
# https://trac.ffmpeg.org/wiki/Encode/H.264
|
||||
# https://trac.ffmpeg.org/wiki/Encode/VP8
|
||||
# -qmin 0 (0-63, default 4, lower = better quality)
|
||||
# -qmax 40 (qmin-63, default 63)
|
||||
# -crf 16 (0-51, default 23, 0 = lossless)
|
||||
# -b:v 4M
|
||||
ffmpeg -threads 4 -i "$1" -c:v libvpx -qmin 0 -qmax 40 -crf 16 -b:v 4M "$AUDIO" "${1%.*}_convert.webm"
|
||||
}
|
||||
|
||||
ytaudio_thumbnail() {
|
||||
# Get file name
|
||||
echo "Retrieving video name.."
|
||||
FILE_NAME="$(youtube-dl --get-filename "$1")"
|
||||
FILE_NAME="${FILE_NAME%.*}"
|
||||
|
||||
# Get mp3 + thumbnail
|
||||
echo "Downloading and converting \"$FILE_NAME\".."
|
||||
youtube-dl -f bestaudio/best -x --audio-format mp3 --audio-quality 0 \
|
||||
--write-thumbnail --cookies "~/documents/youtube.com_cookies.txt" "$1" > /dev/null
|
||||
# --write-thumbnail "$1" > /dev/null
|
||||
|
||||
echo "Embedding thumbnail into mp3.."
|
||||
|
||||
# Convert thumbnail to actually be a jpg
|
||||
yes y | ffmpeg -i "${FILE_NAME}.webp" "${FILE_NAME}_converted.jpg" > /dev/null 2>&1
|
||||
yes y | ffmpeg -i "${FILE_NAME}.jpg" "${FILE_NAME}_converted.jpg" > /dev/null 2>&1
|
||||
|
||||
# Embed thumbnail into mp3
|
||||
yes y | ffmpeg -i "${FILE_NAME}.mp3" -i "${FILE_NAME}_converted.jpg" \
|
||||
-map 0:0 -map 1:0 -c copy -id3v2_version 3 \
|
||||
-metadata:s:v title="Album cover" \
|
||||
-metadata:s:v comment="Cover (front)" \
|
||||
"${FILE_NAME}_embed.mp3" > /dev/null 2>&1
|
||||
|
||||
# Remove left over files
|
||||
rm -f "./${FILE_NAME}_converted.jpg" "./${FILE_NAME}.jpg" "./${FILE_NAME}.mp3"
|
||||
mv "${FILE_NAME}_embed.mp3" "${FILE_NAME}.mp3"
|
||||
}
|
||||
|
||||
"$@"
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Control the display brightness
|
||||
# Depends: brightnessctl
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
brictl - control the display brightness
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}brictl${N} [${U}OPTION${N}] [${U}COMMAND${N}] [<${U}ARG${N}>]
|
||||
|
||||
${B}DESCRIPTION${N}
|
||||
${B}brictl${N} uses brightnessctl to change the brightness of the system.
|
||||
|
||||
Commands can be truncated, i.e. "${B}brictl s${N}" for "${B}brictl set${N}"
|
||||
Arguments need to be of numeric value.
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}-h${N} Display usage message and exit.
|
||||
|
||||
${B}COMMANDS${N}
|
||||
${B}i${N} <${U}AMOUNT${N}>, ${B}inc${N} <${U}AMOUNT${N}>
|
||||
Increase brightness by ${U}AMOUNT${N}, default of 5.
|
||||
|
||||
${B}d${N} <${U}AMOUNT${N}>, ${B}dec${N} <${U}AMOUNT${N}>
|
||||
Decrease brightness by ${U}AMOUNT${N}, default of 5.
|
||||
|
||||
${B}s${N} <${U}LEVEL${N}>, ${B}set${N} <${U}LEVEL${N}>
|
||||
Set brightness to ${U}LEVEL${N}, default of 30.
|
||||
|
||||
${B}g${N}, ${B}get${N}
|
||||
Get brightness level.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Exit if no option is provided
|
||||
[ "$#" -eq 0 ] && help && exit 1
|
||||
|
||||
SCRIPT="$(basename "$0")"
|
||||
|
||||
# Option handling
|
||||
while getopts ':h?' opt; do
|
||||
case $opt in
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "$SCRIPT: invalid option '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Command handling
|
||||
shift $((OPTIND - 1))
|
||||
case "$1" in
|
||||
i*)
|
||||
NUM=${2:-5}
|
||||
brightnessctl -q s +"$NUM"%
|
||||
;;
|
||||
d*)
|
||||
NUM=${2:-5}
|
||||
brightnessctl -q s "$NUM"%-
|
||||
;;
|
||||
s*)
|
||||
NUM=${2:-30}
|
||||
brightnessctl -q s "$NUM"%
|
||||
;;
|
||||
g*)
|
||||
brightnessctl | awk '/%/ {print substr($4, 2, length($4) - 3)}'
|
||||
;;
|
||||
*)
|
||||
echo "$SCRIPT: invalid command '$1'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Bulk rename files inside a directory
|
||||
# Depends:
|
||||
|
||||
# User-config-------------------------------
|
||||
|
||||
# Define editor to open file in
|
||||
set -- emacsclient -a ''
|
||||
|
||||
# ------------------------------------------
|
||||
|
||||
format() {
|
||||
b=$(tput bold)
|
||||
blue=$(tput setf 1)
|
||||
n=$(tput sgr0)
|
||||
|
||||
echo "${b}${blue}::${n}${b} ${1}${n}"
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
[ -f "$tmpfile" ] && rm -f "$tmpfile"
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
signal() {
|
||||
echo
|
||||
cleanup 1
|
||||
}
|
||||
|
||||
# ------------------------------------------
|
||||
|
||||
# Get all filenames in the current directory
|
||||
files=$(find . -maxdepth 1 -type f -printf '%P\n' | sort)
|
||||
|
||||
# Write all filesnames to tmpfile
|
||||
tmpfile=$(mktemp)
|
||||
trap signal HUP INT TERM
|
||||
echo "$files" > "$tmpfile"
|
||||
|
||||
# Open tmpfile in editor, wait to continue
|
||||
md5_before=$(md5sum "$tmpfile")
|
||||
format "Waiting for editor..."
|
||||
"$@" "$tmpfile" > /dev/null
|
||||
md5_after=$(md5sum "$tmpfile")
|
||||
|
||||
# Exit if nothing was changed
|
||||
[ "$md5_before" = "$md5_after" ] && cleanup 1
|
||||
|
||||
# Exit on mismatch entry size
|
||||
lines_before=$(echo "$files" | wc -l)
|
||||
lines_after=$(wc -l "$tmpfile" | cut -d ' ' -f 1)
|
||||
if [ "$lines_before" != "$lines_after" ]; then
|
||||
echo "File amount mismatch!"
|
||||
cleanup 1
|
||||
fi
|
||||
|
||||
# Exit if file has a space
|
||||
if grep -Fq ' ' "$tmpfile"; then
|
||||
echo "Filenames with spaces are not supported!"
|
||||
cleanup 1
|
||||
fi
|
||||
|
||||
# Create file commands
|
||||
i=1
|
||||
for file in $files; do
|
||||
newFile=$(sed -n "${i}p" "$tmpfile")
|
||||
|
||||
if [ "$file" = "$newFile" ]; then
|
||||
command=""
|
||||
else
|
||||
[ -z "$newFile" ] && command="rm -f ${file}" || command="mv ${file} \0"
|
||||
fi
|
||||
|
||||
sed -i "${i}s/.*/${command}/;" "$tmpfile" > /dev/null
|
||||
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
# Delete empty lines
|
||||
sed -Ei '/^\s*$/d' "$tmpfile"
|
||||
|
||||
# Display commands
|
||||
prompt=$(cat "$tmpfile")
|
||||
printf "\n%s\n\n" "$prompt"
|
||||
|
||||
# Confirm with user
|
||||
prompt=$(format "Proceed with execution? [Y/n]")
|
||||
printf "%s " "$prompt"
|
||||
read -r execute
|
||||
|
||||
# Execute file commands
|
||||
if [ "$execute" = "" ] || [ "$execute" = "y" ] || [ "$execute" = "Y" ]; then
|
||||
format "Executing commands..."
|
||||
sh "$tmpfile"
|
||||
else
|
||||
cleanup 1
|
||||
fi
|
||||
|
||||
cleanup
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script that searches config files and scripts
|
||||
|
||||
# User-config---------------------------
|
||||
|
||||
# Define editor to open file in and if it should fork
|
||||
EDITOR="aliases emacs"
|
||||
BACKGROUND=""
|
||||
|
||||
# List of directories to exclude
|
||||
EXCLUDES="
|
||||
code
|
||||
documents
|
||||
dotfiles
|
||||
downloads
|
||||
pictures
|
||||
.cache
|
||||
.clangd
|
||||
.config/chromium
|
||||
.config/emacs/elpa
|
||||
.config/ElectronChrome
|
||||
.config/vim/pack/plugins
|
||||
.electron-gyp
|
||||
.emacs.d/elpa
|
||||
.gradle
|
||||
.jd
|
||||
.local/share
|
||||
.mozilla/firefox/dotfiles.profile/storage
|
||||
.node-gyp
|
||||
.npm
|
||||
.nvm
|
||||
.wine
|
||||
"
|
||||
|
||||
# List of files to include
|
||||
INCLUDES="
|
||||
documents/vm/backup/backup.sh
|
||||
documents/vm/commands.org
|
||||
dotfiles/dotfiles.sh
|
||||
"
|
||||
|
||||
# --------------------------------------
|
||||
|
||||
# Execute relative to $HOME
|
||||
cd "$HOME" || exit 1
|
||||
|
||||
# Generate exclude string to use with find
|
||||
for EXCLUDE in $EXCLUDES; do
|
||||
EXCLUDE_STRING="$EXCLUDE_STRING -path ./$EXCLUDE -o"
|
||||
done
|
||||
EXCLUDE_STRING=${EXCLUDE_STRING%???}
|
||||
|
||||
# Find the files
|
||||
FILES="$( (find . \( $EXCLUDE_STRING \) -prune -o -type f -printf '%P\n'; echo "$INCLUDES") \
|
||||
| grep -vx "" | sort)"
|
||||
|
||||
# If no name provided
|
||||
if [ -z "$1" ]; then
|
||||
SELECTED="$(printf "%s" "$FILES" | rofi -dmenu -p "Select file to edit")"
|
||||
|
||||
# Else try to search for that file
|
||||
else
|
||||
SELECTED="$(printf "%s" "$FILES" | grep "$1" | head -n 1)"
|
||||
fi
|
||||
|
||||
# Exit if nothing selected
|
||||
if [ -z "$SELECTED" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Start editor with selected file
|
||||
if [ -z "$BACKGROUND" ]; then
|
||||
$EDITOR "$SELECTED"
|
||||
else
|
||||
$EDITOR "$SELECTED" > /dev/null 2>&1 &
|
||||
fi
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Control the input devices
|
||||
# Depends: xinput, setxkbmap
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
inputctl - control the input devices
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}inputctl${N} ${U}OPTION${N} [${U}ARG${N}]
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}-h${N} Display usage message and exit.
|
||||
|
||||
${B}-d${N} ${U}STATE${N}
|
||||
Set touchpad state, possible values: toggle, on/off, 1/0.
|
||||
|
||||
${B}-k${N} ${U}STATE${N}
|
||||
Set keyboard state, possible values: toggle, on/off, 1/0.
|
||||
|
||||
${B}-s${N} ${U}STATE${N}
|
||||
Set touchscreen state, possible values: toggle, on/off, 1/0.
|
||||
EOF
|
||||
}
|
||||
|
||||
setxkbmap -option caps:swapescape
|
||||
|
||||
# Exit if no option is provided
|
||||
[ "$#" -eq 0 ] && help && exit 1
|
||||
|
||||
# Set required X variables
|
||||
export DISPLAY=:0
|
||||
export XAUTHORITY="$XDG_DATA_HOME/xorg/Xauthority"
|
||||
|
||||
# Option handling
|
||||
SCRIPT="$(basename "$0")"
|
||||
while getopts ':h?d:k:s:' opt; do
|
||||
case $opt in
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
d)
|
||||
OPTION="d"
|
||||
ARG="$OPTARG"
|
||||
DEV="SYNA3602:00 0911:5288 Touchpad"
|
||||
;;
|
||||
k)
|
||||
OPTION="k"
|
||||
ARG="$OPTARG"
|
||||
;;
|
||||
s)
|
||||
OPTION="s"
|
||||
ARG="$OPTARG"
|
||||
DEV="pointer:04F3200A:00 04F3:2373"
|
||||
;;
|
||||
:)
|
||||
echo "$SCRIPT: option requires an argument '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
\?)
|
||||
echo "$SCRIPT: invalid option '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
toggle_device() {
|
||||
STATUS=$(xinput --list-props "$2" | awk '/Device Enabled/ { print $4 }')
|
||||
[ "$STATUS" -eq 1 ] && xinput --disable "$2" || xinput --enable "$2"
|
||||
}
|
||||
|
||||
device() {
|
||||
case "$1" in
|
||||
1 | on)
|
||||
xinput --enable "$2"
|
||||
;;
|
||||
0 | off)
|
||||
xinput --disable "$2"
|
||||
;;
|
||||
t*)
|
||||
toggle_device "$2"
|
||||
;;
|
||||
*)
|
||||
echo "$SCRIPT: invalid argument '$1'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
keyboard() {
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
if [ "$1" = "toggle" ]; then
|
||||
if setxkbmap -query | grep -q options; then
|
||||
keyboard "off"
|
||||
else
|
||||
keyboard "on"
|
||||
fi
|
||||
|
||||
elif [ "$1" = "on" ]; then
|
||||
# Swap caps lock with escape
|
||||
setxkbmap -option caps:swapescape
|
||||
|
||||
# Swap left crtl with left alt
|
||||
# setxkbmap -option ctrl:swap_lalt_lctl
|
||||
|
||||
# Set touchpad toggle keyboard symbol
|
||||
# xmodmap -e "keycode 93 = XF86iTouch"
|
||||
|
||||
elif [ "$1" = "off" ]; then
|
||||
# Clear all key mappings
|
||||
setxkbmap -option ''
|
||||
fi
|
||||
}
|
||||
|
||||
# Option execution
|
||||
# if [ "$DEV" = "Keyboard" ]; then
|
||||
# keyboard "$ARG"
|
||||
# else
|
||||
case "$OPTION" in
|
||||
d | s)
|
||||
device "$ARG" "$DEV"
|
||||
;;
|
||||
k)
|
||||
keyboard "$ARG"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Useful input diagnostics packages:
|
||||
# - xinput
|
||||
# - xev
|
||||
# - evtest
|
||||
#
|
||||
# - setxkbmap -query
|
||||
# - xmodmap -pke
|
||||
|
||||
# https://superuser.com/questions/437053/firefox-doesnt-recognize-my-alt-keys-anymore
|
||||
# https://www.x.org/releases/X11R7.7/doc/xorg-docs/input/XKB-Config.html
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/bin/sh
|
||||
|
||||
BACKUP_COUNT_MAX=5
|
||||
|
||||
# Backup individual files
|
||||
FILES="
|
||||
/etc/netctl/eth0-dhcp
|
||||
"
|
||||
|
||||
# Backup all files from folder
|
||||
FOLDER_FILES="
|
||||
/etc/netctl
|
||||
"
|
||||
|
||||
# Backup complete folder (recursively)
|
||||
FOLDERS="
|
||||
/etc/netctl
|
||||
"
|
||||
|
||||
# Database credentials
|
||||
USER="username"
|
||||
PASSWORD="password"
|
||||
HOST="127.0.0.1"
|
||||
|
||||
# Database names
|
||||
DATABASES="
|
||||
example
|
||||
example2
|
||||
"
|
||||
|
||||
# ------------------------------------ #
|
||||
|
||||
### Remove / create backup directories ###
|
||||
|
||||
if [ "$(dirname "$0")" != "." ]; then
|
||||
echo "Please run this script from the directory it resides."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# All directories
|
||||
BACKUP_FILES="$(find . -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort -r)"
|
||||
|
||||
# Current amount of backups
|
||||
BACKUP_COUNT=$(echo "$BACKUP_FILES" | wc -l)
|
||||
|
||||
# Remove the oldest backup folders
|
||||
if [ "$BACKUP_COUNT" -ge $BACKUP_COUNT_MAX ]; then
|
||||
BACKUPS_OLDEST="$(echo "$BACKUP_FILES" | sed -nE "
|
||||
1,${BACKUP_COUNT_MAX}d;
|
||||
s/^([0-9]{2}|-|_|:){12}$/\0/p
|
||||
")"
|
||||
|
||||
printf "%s\n%s\n" "Removing directories:" "$BACKUPS_OLDEST"
|
||||
rm -rf $BACKUPS_OLDEST
|
||||
fi
|
||||
|
||||
# Execution location
|
||||
DIR="$(pwd)"
|
||||
|
||||
# Create new backup folder
|
||||
BACKUP_NAME="$(date +%Y-%m-%d_%H:%M:%S)"
|
||||
mkdir "$DIR/$BACKUP_NAME"
|
||||
|
||||
### Start backup procedure ###
|
||||
|
||||
# Individual files
|
||||
for FILE in $FILES; do
|
||||
mkdir -p "$DIR/$BACKUP_NAME/$(dirname "$FILE")"
|
||||
cp -a "$FILE" "$DIR/$BACKUP_NAME/$FILE"
|
||||
done
|
||||
|
||||
# All files inside folder
|
||||
for FOLDER_FILE in $FOLDER_FILES; do
|
||||
mkdir -p "$DIR/$BACKUP_NAME/$FOLDER_FILE"
|
||||
|
||||
# Usind find -> read ensures filename space support
|
||||
find "$FOLDER_FILE" -maxdepth 1 -type f | while read -r FILE; do
|
||||
cp "$FILE" "$DIR/$BACKUP_NAME/$FILE"
|
||||
done
|
||||
done
|
||||
|
||||
# Complete folder
|
||||
for FOLDER in $FOLDERS; do
|
||||
mkdir -p "$DIR/$BACKUP_NAME/$FOLDER"
|
||||
cp -r "$FOLDER" "$DIR/$BACKUP_NAME/$(dirname "$FOLDER")"
|
||||
done
|
||||
|
||||
# Set default file permissions
|
||||
umask 177
|
||||
# MYSQL Dump
|
||||
for DATABASE in $DATABASES; do
|
||||
# mysqldump --user=$USER --protocol=socket -S /var/run/mysqld/mysqld.sock "$DATABASE" \
|
||||
mysqldump --user=$USER --password=$PASSWORD --host=$HOST "$DATABASE" \
|
||||
> "$DIR/$BACKUP_NAME/$DATABASE-$BACKUP_NAME.sql"
|
||||
done
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Dependencies:
|
||||
# castnow-git
|
||||
# mkvtoolnix-cli
|
||||
# jq
|
||||
|
||||
FILE_NAME="$1"
|
||||
|
||||
TRACKS="$(mkvmerge -J "$FILE_NAME" | jq -c '
|
||||
.tracks[] |
|
||||
select(.type == "subtitles") |
|
||||
{
|
||||
id:.id,
|
||||
codec_id:.properties.codec_id,
|
||||
language:.properties.language,
|
||||
track_name:.properties.track_name
|
||||
}')"
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
SELECTION=$2
|
||||
else
|
||||
echo "$TRACKS"
|
||||
echo -n "Choose a subtitle ID: "
|
||||
read -r SELECTION
|
||||
fi
|
||||
|
||||
if [ -z "$(echo $SELECTION | sed -nr 's/^([0-9]+)$/\1/p')" ]; then
|
||||
echo "Please select a number"
|
||||
exit
|
||||
fi
|
||||
|
||||
for TRACK in $TRACKS; do
|
||||
TRACK_ID=$(echo $TRACK | sed -nr 's/.*"id":([0-9]+),.*/\1/p')
|
||||
if [ $TRACK_ID != $SELECTION ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
CODEC_ID="$(echo $TRACK | \
|
||||
sed -nr 's/.*"codec_id":"(S_[A-Z]+\/?[A-Z]*[0-9]*)",.*/\1/p')"
|
||||
|
||||
if [ "$CODEC_ID" = "S_TEXT/UTF8" ]; then
|
||||
EXT="srt"
|
||||
elif [ "$CODEC_ID" = "S_TEXT/ASS" ]; then
|
||||
EXT="ssa"
|
||||
elif [ "$CODEC_ID" = "S_TEXT/USF" ]; then
|
||||
EXT="usf"
|
||||
elif [ "$CODEC_ID" = "S_VOBSUB" ]; then
|
||||
EXT="sub"
|
||||
elif [ "$CODEC_ID" = "S_HDMV/PGS" ]; then
|
||||
EXT="sup"
|
||||
fi
|
||||
|
||||
echo "Extracting subtitle.."
|
||||
mkvextract tracks "$FILE_NAME" $TRACK_ID:/tmp/sub."$EXT" 2>&1 >/dev/null
|
||||
|
||||
echo "Converting subtitle.."
|
||||
ffmpeg -y -i /tmp/sub."$EXT" /tmp/sub.vtt 2>/dev/null
|
||||
|
||||
echo "Playing file.."
|
||||
castnow "$FILE_NAME" --subtitles /tmp/sub.vtt --subtitle-scale 1.2 --subtitle-color FFFFFFFF
|
||||
done
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
|
||||
MAIN_DISPLAY="eDP-1"
|
||||
MAIN_MODE="--mode 3000x2000_48.00 --primary"
|
||||
|
||||
popup() {
|
||||
echo "$1" | rofi -dmenu -i -p "$2" \
|
||||
-color-window "#524040, #dc7a43, #fff" \
|
||||
-color-normal "#524040, #fff, #524040, #fff, #707880" \
|
||||
-no-fixed-num-lines
|
||||
}
|
||||
|
||||
multiDisplay() {
|
||||
case "$(echo "$CONNECTED" | wc -l)" in
|
||||
1) setSingle ;;
|
||||
2) setDual ;;
|
||||
*) setMulti ;;
|
||||
esac
|
||||
}
|
||||
|
||||
setSingle() {
|
||||
[ "$CHOOSE" = "$MAIN_DISPLAY" ] && MODE="$MAIN_MODE" || MODE="--auto"
|
||||
|
||||
# Disconnect all other displays
|
||||
eval xrandr --output "$CHOOSE" "$MODE" \
|
||||
"$(echo "$CONNECTED" | grep -vx "$CHOOSE" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ')"
|
||||
}
|
||||
|
||||
setDual() {
|
||||
PRIMARY=$(popup "$CONNECTED" "Select primary display")
|
||||
[ "$PRIMARY" = "$MAIN_DISPLAY" ] && MODE="$MAIN_MODE" || MODE="--auto"
|
||||
|
||||
SECONDARY=$(echo "$CONNECTED" | grep -vx "$PRIMARY")
|
||||
SIDE=$(popup "$(printf "right\nleft")" "On which side of $PRIMARY should $SECONDARY be?")
|
||||
eval xrandr --output "$PRIMARY" "$MODE" --output "$SECONDARY" --"$SIDE"-of "$PRIMARY" --auto
|
||||
}
|
||||
|
||||
setMulti() {
|
||||
# @Todo
|
||||
echo "Todo"
|
||||
}
|
||||
|
||||
# Get all connected displays
|
||||
CONNECTED=$(xrandr -q | grep " connected" | awk '{print $1}')
|
||||
|
||||
# Add Multi-monitor and Manual selection to the selectable options
|
||||
SELECTION="$(printf "%s\nMulti-monitor\nManual selection" "$CONNECTED")"
|
||||
|
||||
# Get user selection
|
||||
CHOOSE="$(popup "$SELECTION" "Select display arangement")" &&
|
||||
case "$CHOOSE" in
|
||||
"Manual selection") arandr 2> /dev/null ; exit ;;
|
||||
"Multi-monitor") multiDisplay ;;
|
||||
*) setSingle ;;
|
||||
esac
|
||||
|
||||
# Reload background
|
||||
$HOME/.local/bin/wm/wallpaper.sh
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
monctl - monitor manager
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}monctl${N} [${U}OPTION${N}] [${U}ARG(S)${N}]
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}a*${N} ${U}width${N} ${U}height${N} ${U}hertz${N} ${U}name${N}
|
||||
Setup single monitor with new mode.
|
||||
|
||||
${B}p*${N} ${U}name${N} ${U}mode${N}
|
||||
Setup single primary monitor.
|
||||
|
||||
${B}ARGS${N}
|
||||
width
|
||||
Pixel width of the monitor.
|
||||
|
||||
height
|
||||
Pixel height of the monitor.
|
||||
|
||||
hertz
|
||||
Refresh rate of the monitor.
|
||||
|
||||
name
|
||||
Xrandr name of the monitor.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Exit if no option is provided
|
||||
[ "$#" -eq 0 ] && help && exit 1
|
||||
|
||||
# Set required X variables
|
||||
export DISPLAY=:0
|
||||
export XAUTHORITY="$XDG_DATA_HOME/xorg/Xauthority"
|
||||
|
||||
update() {
|
||||
sleep 4
|
||||
|
||||
# Reconfigure desktops
|
||||
"$HOME/.local/bin/wm/desktops.sh"
|
||||
sleep 1
|
||||
|
||||
# Restart panel
|
||||
"$HOME/.local/bin/panel/polybar.sh" &
|
||||
|
||||
# Reload wallpaper
|
||||
"$HOME/.local/bin/wm/wallpaper.sh" &
|
||||
}
|
||||
|
||||
auto() {
|
||||
[ "$#" != "4" ] && return 1
|
||||
|
||||
# Add mode to primary monitor
|
||||
OUTPUT="$(xrandr -q)"
|
||||
if ! echo "$OUTPUT" | grep -Fq "$1x$2_$3.00"; then
|
||||
eval xrandr --newmode $(cvt "$1" "$2" "$3" | awk '/Modeline/{ $1=""; print $0 }')
|
||||
xrandr --addmode "$4" "$1x$2_$3.00"
|
||||
fi
|
||||
|
||||
primary "$4" "--mode $1x$2_$3.00"
|
||||
}
|
||||
|
||||
primary() {
|
||||
[ "$#" != "1" ] && [ "$#" != "2" ] && return 1
|
||||
MODE=${2:-"--auto"}
|
||||
|
||||
# Get all connected monitors
|
||||
CONNECTED="$(xrandr -q | awk '/ connected/{ print $1 }')"
|
||||
|
||||
# Disable all other monitors
|
||||
eval xrandr --output "$1" "$MODE" --primary \
|
||||
"$(echo "$CONNECTED" | grep -vx "$1" | awk '{ print "--output", $1, "--off" }' | tr '\n' ' ')"
|
||||
|
||||
# Post monitor change
|
||||
update
|
||||
}
|
||||
|
||||
[ $OPTIND -ge 2 ] && shift $((OPTIND - 2))
|
||||
case "$1" in
|
||||
a*)
|
||||
shift 1
|
||||
auto "$@"
|
||||
;;
|
||||
p*)
|
||||
shift 1
|
||||
primary "$@"
|
||||
;;
|
||||
*)
|
||||
help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Control the network interfaces
|
||||
# Depends: iproute2, netctl
|
||||
|
||||
WIRELESS="wlan0"
|
||||
ETHERNET="eth0"
|
||||
PROFILE="eth0-dhcp"
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
netictl - control the network interfaces
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}netictl${N} ${U}OPTION${N} [${U}ARG${N}]
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}-h${N} Display usage message and exit.
|
||||
|
||||
${B}-e${N} ${U}STATE${N}
|
||||
Set ethernet ${U}STATE${N}, possible values: on/off, 1/0.
|
||||
|
||||
${B}-w${N} ${U}STATE${N}
|
||||
Set wireless ${U}STATE${N}, possible values: on/off, 1/0.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Exit if no option is provided
|
||||
[ "$#" -eq 0 ] && help && exit 1
|
||||
|
||||
SCRIPT="$(basename "$0")"
|
||||
|
||||
# Option handling
|
||||
while getopts ':h?e:w:' opt; do
|
||||
case $opt in
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
e)
|
||||
DEV="ethernet"
|
||||
ARG="$OPTARG"
|
||||
;;
|
||||
w)
|
||||
DEV="wireless"
|
||||
ARG="$OPTARG"
|
||||
;;
|
||||
:)
|
||||
echo "$SCRIPT: option requires an argument '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
\?)
|
||||
echo "$SCRIPT: invalid option '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
ethernet() {
|
||||
sudo netctl stop $PROFILE
|
||||
sudo ip link set $ETHERNET down
|
||||
|
||||
if [ "$1" -eq 1 ]; then
|
||||
sudo netctl start $PROFILE
|
||||
fi
|
||||
}
|
||||
|
||||
wireless() {
|
||||
if [ "$1" -eq 1 ]; then
|
||||
sudo ip link set $WIRELESS up
|
||||
else
|
||||
sudo ip link set $WIRELESS down
|
||||
fi
|
||||
}
|
||||
|
||||
# Arg handling
|
||||
case "$ARG" in
|
||||
1 | on)
|
||||
[ "$DEV" = "ethernet" ] && ethernet 1 || wireless 1
|
||||
;;
|
||||
0 | off)
|
||||
[ "$DEV" = "ethernet" ] && ethernet 0 || wireless 0
|
||||
;;
|
||||
*)
|
||||
echo "$SCRIPT: invalid argument '$ARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,20 @@
|
||||
#+LANGUAGE: en
|
||||
#+OPTIONS: toc:nil num:nil
|
||||
|
||||
* Polybar
|
||||
|
||||
Panel configuration.
|
||||
|
||||
** Dependencies
|
||||
|
||||
| Package | Script(s) |
|
||||
|--------------+------------|
|
||||
| acpi | battery.sh |
|
||||
|--------------+------------|
|
||||
| iw | wifi.sh |
|
||||
|--------------+------------|
|
||||
| libnotify-id | battery.sh |
|
||||
| | iface.sh |
|
||||
| | wifi.sh |
|
||||
|--------------+------------|
|
||||
| polybar | polybar.sh |
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
BAT_INFO=${BLOCK_INSTANCE:-"$(acpi -b | grep ': [^Unknown]')"}
|
||||
|
||||
CAPACITY=$(echo "$BAT_INFO" | awk '{ print int($4) }')
|
||||
|
||||
if [ "$(echo "$BAT_INFO" | awk '{ print $6 }')" = "remaining" ]; then
|
||||
if [ "$CAPACITY" -lt "20" ]; then
|
||||
notify-send -u critical -r 1 -t 30000 "Battery critically low!"
|
||||
fi
|
||||
elif [ "$CAPACITY" -ge "95" ]; then
|
||||
notify-send -u low -r 1 "You should probably unplug."
|
||||
fi
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Enable mathematics in POSIX shell
|
||||
calc() { awk "BEGIN { printf(\"%.2f\", $*) }"; }
|
||||
|
||||
data() {
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
url="$1"
|
||||
curl --location --request GET --silent "$url"
|
||||
}
|
||||
|
||||
output() {
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
# Get symbol and color
|
||||
difference="$1"
|
||||
possitive=$(calc "$difference >= 0" | cut -c 1)
|
||||
if [ "$possitive" -eq 1 ]; then
|
||||
symbol=""
|
||||
color="$COLOR2"
|
||||
else
|
||||
symbol=""
|
||||
color="$COLOR1"
|
||||
fi
|
||||
|
||||
# Result
|
||||
echo "%{F$color}$symbol $difference%%{F$COLOR15}"
|
||||
}
|
||||
|
||||
# Get dates
|
||||
date_last_week_start="$(date --date 'last week' +%s000)"
|
||||
date_last_week_end=$(calc "$date_last_week_start + (1000 * 60 * 60)") # +1h
|
||||
date_last_week_end=${date_last_week_end%.00} # cut off ".00" at the end
|
||||
|
||||
# API URLs
|
||||
url="https://api.coincap.io/v2/assets/bitcoin"
|
||||
url_last_week="${url}/history?interval=h1&start=${date_last_week_start}&end=${date_last_week_end}"
|
||||
|
||||
# Current price
|
||||
data="$(data "$url")"
|
||||
price="$(echo "$data" | jq --compact-output --raw-output '.data.priceUsd')"
|
||||
price=$(calc "$price")
|
||||
|
||||
# Get yesterdays difference
|
||||
difference_yesterday="$(echo "$data" | jq --compact-output --raw-output '.data.changePercent24Hr')"
|
||||
difference_yesterday="$(calc "$difference_yesterday")"
|
||||
|
||||
# Get last weeks difference
|
||||
price_last_week="$(data "$url_last_week" | jq --compact-output --raw-output '.data[0].priceUsd')"
|
||||
difference_last_week=$(calc "$price / $price_last_week * 100 - 100")
|
||||
|
||||
# Create output formatting
|
||||
difference_yesterday_output="d $(output "$difference_yesterday")"
|
||||
difference_last_week_output="w $(output "$difference_last_week")"
|
||||
|
||||
echo "\$$price $difference_yesterday_output $difference_last_week_output"
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
DATE="$(date +'%A, %B %d, %Y')"
|
||||
|
||||
notify-send -r 3 "Date" "\
|
||||
$DATE"
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
WIRED="${1:-eth0}"
|
||||
|
||||
IP="$(ip a show "$WIRED" \
|
||||
| awk '/inet / { print substr($2, 0, length($2) - 3) }')"
|
||||
|
||||
notify-send -r 3 "Wired" "\
|
||||
Interface: $WIRED
|
||||
IP: $IP"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Kill existing panels
|
||||
while [ "$(pgrep -cx polybar)" -gt 1 ]; do
|
||||
pkill -x -9 polybar;
|
||||
done
|
||||
|
||||
# Start a panel on each monitor
|
||||
for m in $(polybar --list-monitors | cut -d ":" -f1); do
|
||||
MONITOR=$m polybar --reload polybar &
|
||||
done
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
WIRELESS="${1:-wlan0}"
|
||||
|
||||
SSID="$(iw dev "$WIRELESS" link | awk '/SSID/ { print $2 }')"
|
||||
IP="$(ip a show "$WIRELESS" \
|
||||
| awk '/inet / { print substr($2, 0, length($2) - 3) }')"
|
||||
|
||||
notify-send -r 3 "Wifi" "\
|
||||
Interface: $WIRELESS
|
||||
SSID: $SSID
|
||||
IP: $IP"
|
||||
Executable
+110
@@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
|
||||
PIPE="$XDG_CACHE_HOME/mpv/umpv_fifo"
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
play - mpv playback functions
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}play${N} [${U}OPTION${N}] [${U}ARGS${N}...]
|
||||
|
||||
${B}DESCRIPTION${N}
|
||||
play is a script to manage different mpv viewing bahavior.
|
||||
If no ${U}URLS${N} argument is provided, it is read from clipboard instead.
|
||||
The queue option starts a mpv window with a playlist, which all videos of
|
||||
subsequent queue calls get added to.
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}help${N}
|
||||
Display usage message and exit.
|
||||
|
||||
[${B}play${N}] [${U}URLS${N}...] (default)
|
||||
Plays videos in a new mpv window.
|
||||
|
||||
${B}shuffle${N} [${U}URLS${N}...]
|
||||
Shuffle audio playlist (disables video playback).
|
||||
|
||||
${B}queue${N} [${U}URLS${N}...]
|
||||
Add multiple videos to the unique mpv's queue.
|
||||
EOF
|
||||
}
|
||||
|
||||
CLIP="$(xclip -se c -o)"
|
||||
|
||||
play() {
|
||||
if [ -z "$1" ]; then
|
||||
MPV="mpv $CLIP"
|
||||
# Cut off everything after space
|
||||
LINK=" $(echo $CLIP | sed -nE 's/^(\S+).*/\1/p')"
|
||||
else
|
||||
MPV="mpv $*"
|
||||
# Determain which argument holds the urls
|
||||
[ "$1" = "${1#-}" ] && DISPLAY="$1" || DISPLAY="$2"
|
||||
# Cut off everything after space
|
||||
LINK=" $(echo $DISPLAY | sed -nE 's/^(\S+).*/\1/p')"
|
||||
fi
|
||||
|
||||
notify-send -t 2500 "Loading video: $LINK"
|
||||
# Attempt to load video
|
||||
[ "$($MPV)" ] && notify-send -u critical -t 4000 "Loading video failed.."
|
||||
}
|
||||
|
||||
shuffle() {
|
||||
# Skip first argument
|
||||
shift 1
|
||||
mpv --no-video --shuffle --ytdl-format='bestaudio[ext=m4a]' "${@:-$CLIP}"
|
||||
}
|
||||
|
||||
queue() {
|
||||
OPTIONS="--no-terminal --force-window --input-file=$PIPE"
|
||||
|
||||
# Create mpv cache directory
|
||||
DIR="$(dirname "$PIPE")"
|
||||
[ ! -d "$DIR" ] && mkdir -p "$DIR"
|
||||
|
||||
# Delete named pipe if no umpv is running
|
||||
if ! pgrep -f 'mpv $OPTIONS' > /dev/null; then
|
||||
rm -f "$PIPE"
|
||||
fi
|
||||
|
||||
# Skip first argument
|
||||
shift 1
|
||||
# Set url to argument if provided, clipboard otherwise
|
||||
URLS="${@:-$CLIP}"
|
||||
|
||||
if [ -p $PIPE ]; then
|
||||
notify-send -t 2500 "Added video to queue.."
|
||||
# Add video to named pipe
|
||||
echo "$URLS" \
|
||||
| awk -v RS=' ' '{ print "raw loadfile "$1" append" }' > "$PIPE"
|
||||
else
|
||||
# Create named pipe
|
||||
mkfifo "$PIPE"
|
||||
|
||||
# Play video
|
||||
play "$OPTIONS" "$URLS"
|
||||
|
||||
rm -f "$PIPE"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
help)
|
||||
help
|
||||
;;
|
||||
shuffle)
|
||||
shuffle "$@"
|
||||
;;
|
||||
queue)
|
||||
queue "$@"
|
||||
;;
|
||||
*)
|
||||
play "$@"
|
||||
;;
|
||||
esac
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Ask password script. SUDO_ASKPASS is set to this script.
|
||||
|
||||
rofi -password -no-fixed-num-lines -dmenu -p "Password"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Binary prompt script.
|
||||
# Prompt rofi with label $1 to perform command $2.
|
||||
#
|
||||
# Example:
|
||||
# $ rofiprompt "Are you sure you want to shutdown?" "poweroff"
|
||||
|
||||
[ "$(printf 'No\nYes' | rofi -dmenu -i -p "$1" -lines 2 \
|
||||
-color-window "#524040, #dc7a43, #fff" \
|
||||
-color-normal "#524040, #fff, #524040, #fff, #707880")" = "Yes" ] && $2
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Rofi prompt for system functions.
|
||||
|
||||
if [ "$WM" = "bspwm" ]; then
|
||||
logout="bspc quit"
|
||||
elif [ "$WM" = "i3" ]; then
|
||||
logout="i3-msg exit"
|
||||
fi
|
||||
|
||||
commands="\
|
||||
Lock:$HOME/.scripts/wm/lock.sh
|
||||
Suspend:systemctl suspend
|
||||
Shutdown:systemctl poweroff
|
||||
Reboot:systemctl reboot
|
||||
Logout:$logout"
|
||||
|
||||
choice=$(echo "$commands" | cut -d ':' -f 1 | rofi -no-fixed-num-lines -dmenu -i -p "System") || exit 0
|
||||
|
||||
exec=$(echo "$commands" | grep "^$choice" | cut -d ':' -f 2-)
|
||||
|
||||
eval "$exec"
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file echoes a bunch of color codes to the terminal to demonstrate what's
|
||||
# available. Each line is the color code of one forground color, out of 17
|
||||
# (default + 16 escapes), followed by a test use of that color on all nine
|
||||
# background colors (default + 8 escapes).
|
||||
|
||||
# The test text
|
||||
text="gYw"
|
||||
|
||||
printf "\n 40m 41m 42m 43m\
|
||||
44m 45m 46m 47m\n";
|
||||
|
||||
for fgs in " m" " 1m" " 30m" "1;30m" " 31m" "1;31m" " 32m" \
|
||||
"1;32m" " 33m" "1;33m" " 34m" "1;34m" " 35m" "1;35m" \
|
||||
" 36m" "1;36m" " 37m" "1;37m"; do
|
||||
fg=$(echo "$fgs" | tr -d ' ')
|
||||
printf " %s \033[%s %s " "$fgs" "$fg" "$text"
|
||||
for bg in 40m 41m 42m 43m 44m 45m 46m 47m; do
|
||||
printf " \033[%s\033[%s %s \033[0m" "$fg" "$bg" "$text";
|
||||
done
|
||||
echo
|
||||
done
|
||||
echo
|
||||
Executable
+186
@@ -0,0 +1,186 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Vim plugin manager
|
||||
# Depends: git
|
||||
|
||||
#----
|
||||
BASE="$XDG_CONFIG_HOME/vim/pack"
|
||||
#----
|
||||
DIR="$BASE/plugins"
|
||||
LIST="$BASE/list"
|
||||
START="$DIR/start"
|
||||
OPT="$DIR/opt"
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
vimplugin.sh - vim plugin manager
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}vimplugin.sh${N} [${U}OPTION${N}] [${U}COMMAND${N}] [<${U}ARG${N}>...]
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}-h${N} Display usage message and exit.
|
||||
|
||||
${B}COMMANDS${N}
|
||||
${B}init${N}
|
||||
Creates all the required directories/files.
|
||||
|
||||
${B}install${N} ${U}URL${N} <${U}LOCATION${N}>
|
||||
Install a new plugin from a valid GitHub ${U}URL${N}.
|
||||
Store this plugin in <${U}LOCATION${N}> (start/opt), default to start.
|
||||
|
||||
${B}list${N} <${U}NUMBER${N}>
|
||||
Print all the installed plugins.
|
||||
If <${U}NUMBER${N}> is provided, print only the plugin in that position.
|
||||
|
||||
${B}remove${N}
|
||||
Remove plugin, pick from selection menu.
|
||||
|
||||
${B}update${N}
|
||||
Install/update all plugins stored in the config file.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Exit if no option is provided
|
||||
[ "$#" -eq 0 ] && help && exit 1
|
||||
|
||||
SCRIPT="$(basename "$0")"
|
||||
|
||||
# Option handling
|
||||
while getopts ':h?' opt; do
|
||||
case $opt in
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "$SCRIPT: invalid option '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
init() {
|
||||
sudo mkdir -p "$START"
|
||||
sudo mkdir -p "$OPT"
|
||||
sudo touch "$LIST"
|
||||
if [ ! -s "$LIST" ]; then
|
||||
# Append to empty file
|
||||
sudo sh -c 'echo "start:" >> '"$LIST"
|
||||
sudo sh -c 'echo "opt:" >> '"$LIST"
|
||||
fi
|
||||
}
|
||||
|
||||
install() {
|
||||
# Check if correct git URL
|
||||
if [ -z "$(echo "$1" | sed -nr \
|
||||
's/^https:\/\/github\.com\/(.*\/.*).git$/\1/p')" ]; then
|
||||
echo "$SCRIPT: url invalid: $1"
|
||||
else
|
||||
# cd to correct directory if called from the CLI
|
||||
if [ -z "$2" ]; then
|
||||
# Default is directory 'start'
|
||||
cd "$START" || exit
|
||||
elif [ "$2" = "start" ]; then
|
||||
cd "$START" || exit
|
||||
elif [ "$2" = "opt" ]; then
|
||||
cd "$OPT" || exit
|
||||
fi
|
||||
|
||||
REPO="$(basename "$1" .git)"
|
||||
if [ -d "$REPO" ]; then
|
||||
cd "$REPO" || exit
|
||||
sudo git pull --force 1> /dev/null
|
||||
cd ".."
|
||||
echo "Updated: $REPO"
|
||||
else
|
||||
sudo git clone "$1" 2> /dev/null
|
||||
|
||||
# Add git URL to config file
|
||||
if [ -z "$2" ]; then
|
||||
# Append before 'opt:'
|
||||
sudo sed -i '/opt:/ i '"$1" "$LIST"
|
||||
elif [ "$2" = "start" ]; then
|
||||
# Append before 'opt:'
|
||||
sudo sed -i '/opt:/ i '"$1" "$LIST"
|
||||
elif [ "$2" = "opt" ]; then
|
||||
# Append at the end of the file
|
||||
sudo sed -i '$ a '"$1" "$LIST"
|
||||
fi
|
||||
|
||||
echo "Installed: $REPO"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
list() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Listing all installed plugins.."
|
||||
fi
|
||||
|
||||
PLUGIN="$(find "$DIR" -mindepth 2 -maxdepth 2 \
|
||||
| sort | awk -F '/' '{ print $(NF-1)"/"$NF }')"
|
||||
NUM=0
|
||||
for p in $PLUGIN; do
|
||||
NUM=$((NUM + 1))
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "$NUM) $p"
|
||||
elif [ "$NUM" = "$1" ]; then
|
||||
echo "$p"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
remove() {
|
||||
list
|
||||
printf "Enter the number to remove: "
|
||||
read -r OPTION
|
||||
|
||||
if [ -z "$(echo "$OPTION" | sed -nr 's/^([0-9]+)$/\1/p')" ]; then
|
||||
echo "Please select a number"
|
||||
else
|
||||
TO_REMOVE="$(list "$OPTION")"
|
||||
if [ -n "$TO_REMOVE" ]; then
|
||||
sudo rm -rf "$DIR/$TO_REMOVE"
|
||||
sudo sed -i '/'"$(basename "$TO_REMOVE")"'\.git/d' "$LIST"
|
||||
echo "Removed plugin: $TO_REMOVE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
update() {
|
||||
echo "Updating.."
|
||||
|
||||
init
|
||||
|
||||
cd "$START" || exit
|
||||
while read -r l; do
|
||||
if [ "$l" = "start:" ]; then
|
||||
cd "$START" || exit
|
||||
elif [ "$l" = "opt:" ]; then
|
||||
cd "$OPT" || exit
|
||||
else
|
||||
install "$l" "script"
|
||||
fi
|
||||
done < "$LIST"
|
||||
}
|
||||
|
||||
# Command handling
|
||||
shift $((OPTIND - 1))
|
||||
case "$1" in
|
||||
init | install | list | remove | update)
|
||||
"$@"
|
||||
;;
|
||||
*)
|
||||
echo "$SCRIPT: invalid command '$1'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Executable
+109
@@ -0,0 +1,109 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Control the volume
|
||||
# Depends: pamixer
|
||||
|
||||
help() {
|
||||
B=$(tput bold)
|
||||
U=$(tput smul)
|
||||
N=$(tput sgr0)
|
||||
|
||||
cat << EOF
|
||||
${B}NAME${N}
|
||||
volctl - control the volume
|
||||
|
||||
${B}SYNOPSIS${N}
|
||||
${B}volctl${N} [${U}OPTION${N}] [${U}COMMAND${N}] [<${U}ARG${N}>]
|
||||
|
||||
${B}DESCRIPTION${N}
|
||||
${B}volctl${N} uses pamixer to change the volume of the system.
|
||||
|
||||
Commands can be truncated, i.e. "${B}volctl t${N}" for "${B}volctl toggle${N}"
|
||||
Arguments need to be of numeric value.
|
||||
|
||||
${B}OPTIONS${N}
|
||||
${B}-h${N} Display usage message and exit.
|
||||
|
||||
${B}COMMANDS${N}
|
||||
${B}i${N} <${U}AMOUNT${N}>, ${B}inc${N} <${U}AMOUNT${N}>
|
||||
Increase volume by ${U}AMOUNT${N}, default of 2.
|
||||
|
||||
${B}d${N} <${U}AMOUNT${N}>, ${B}dec${N} <${U}AMOUNT${N}>
|
||||
Decrease volume by ${U}AMOUNT${N}, default of 2.
|
||||
|
||||
${B}s${N} <${U}LEVEL${N}>, ${B}set${N} <${U}LEVEL${N}>
|
||||
Set volume to ${U}LEVEL${N}, default of 0.
|
||||
|
||||
${B}t${N}, ${B}toggle${N}
|
||||
Toggle mute.
|
||||
|
||||
${B}m${N}, ${B}mute${N}
|
||||
Mute volume.
|
||||
|
||||
${B}u${N}, ${B}unmute${N}
|
||||
Unmute volume.
|
||||
|
||||
${B}getv${N}, ${B}getvolume${N}
|
||||
Get volume level.
|
||||
|
||||
${B}getm${N}, ${B}getmute${N}
|
||||
Get mute status.
|
||||
EOF
|
||||
}
|
||||
|
||||
# Exit if no option is provided
|
||||
[ "$#" -eq 0 ] && help && exit 1
|
||||
|
||||
SCRIPT="$(basename "$0")"
|
||||
|
||||
# Option handling
|
||||
while getopts ':h?' opt; do
|
||||
case $opt in
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "$SCRIPT: invalid option '$OPTARG'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Command handling
|
||||
shift $((OPTIND - 1))
|
||||
case "$1" in
|
||||
i*)
|
||||
NUM=${2:-2}
|
||||
pamixer --increase "$NUM"
|
||||
;;
|
||||
d*)
|
||||
NUM=${2:-2}
|
||||
pamixer --decrease "$NUM"
|
||||
;;
|
||||
s*)
|
||||
NUM=${2:-0}
|
||||
pamixer --set-volume "$NUM"
|
||||
;;
|
||||
t*)
|
||||
pamixer --toggle-mute
|
||||
;;
|
||||
m*)
|
||||
pamixer --mute
|
||||
;;
|
||||
n*)
|
||||
pamixer --unmute
|
||||
;;
|
||||
getv*)
|
||||
pamixer --get-volume
|
||||
;;
|
||||
getm*)
|
||||
pamixer --get-mute
|
||||
;;
|
||||
*)
|
||||
echo "$SCRIPT: invalid command '$1'"
|
||||
echo "Try '$SCRIPT -h' for more information."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
for m in `bspc query -M`; do
|
||||
bspc monitor $m -d \
|
||||
"$WS1" "$WS2" "$WS3" "$WS4" "$WS5" \
|
||||
"$WS6" "$WS7" "$WS8" "$WS9" "$WS0"
|
||||
done
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Enable mathematics in POSIX shell
|
||||
calc() { awk "BEGIN{print $*}"; }
|
||||
|
||||
# Calculate size
|
||||
MON_WIDTH=$(xdotool getdisplaygeometry | awk '{print $1}')
|
||||
MON_HEIGHT=$(xdotool getdisplaygeometry | awk '{print $2}')
|
||||
NEW_WIDTH=$(calc "$MON_WIDTH * 0.2")
|
||||
NEW_HEIGHT=$(calc "$NEW_WIDTH / 16 * 9")
|
||||
|
||||
# Calculate position
|
||||
BORDER=23
|
||||
X=$(calc "$MON_WIDTH - $NEW_WIDTH - $BORDER")
|
||||
Y=$(calc "$MON_HEIGHT - $NEW_HEIGHT - $BORDER")
|
||||
|
||||
# Set window
|
||||
CURRENT=$(xdotool getwindowfocus)
|
||||
xdotool windowsize "$CURRENT" "$NEW_WIDTH" "$NEW_HEIGHT"
|
||||
xdotool windowmove "$CURRENT" "$X" "$Y"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOCK="$XDG_CACHE_HOME/lock.png"
|
||||
|
||||
# Cache the lock image
|
||||
if [ ! -f "$LOCK" ]; then
|
||||
touch "$LOCK"
|
||||
|
||||
# Get the resolution of the primary monitor
|
||||
RES="$(xrandr -q | grep ' connected primary' \
|
||||
| grep -Eo '[0-9]{3,4}x[0-9]{3,4}' | head -c -1)"
|
||||
|
||||
# Generate lock image
|
||||
convert "$(dirname "$0")/lock.png" -background none -gravity center -extent "$RES" "$LOCK"
|
||||
fi
|
||||
|
||||
# Disable screensaver
|
||||
revert() {
|
||||
xset s off
|
||||
xset -dpms
|
||||
}
|
||||
|
||||
# Set screensaver to 30 seconds
|
||||
trap revert HUP INT TERM
|
||||
xset +dpms dpms 30 30 30
|
||||
|
||||
i3lock -n -i "$LOCK" -B 6 -S 1 -e \
|
||||
--radius=47 \
|
||||
--ring-width=5.0 \
|
||||
--verifcolor=00000000 \
|
||||
--wrongcolor=00000000 \
|
||||
--timecolor=00000000 \
|
||||
--datecolor=00000000 \
|
||||
--layoutcolor=00000000 \
|
||||
--insidecolor=00000000 \
|
||||
--insidevercolor=00000000 --insidewrongcolor=00000000 \
|
||||
--ringcolor=00000000 \
|
||||
--ringvercolor=FFFFFFC0 --ringwrongcolor=DA2825C0 \
|
||||
--keyhlcolor=FFFFFFC0 --bshlcolor=DA2825C0 \
|
||||
--linecolor=00000000 --separatorcolor=00000000 \
|
||||
-k \
|
||||
--timesize=64 --datesize=24 \
|
||||
--timestr="%I:%M %p" --datestr="%A, %B %e" \
|
||||
--timepos="ix:iy-250" --datepos="ix:iy-200" \
|
||||
--timecolor=FFFFFFC0 --datecolor=FFFFFFC0
|
||||
|
||||
revert
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Overwrite wallpaper with new image if provided
|
||||
[ -n "$1" ] && cp "$1" "$HOME/pictures/wallpaper.jpg"
|
||||
|
||||
# Set wallpaper
|
||||
feh --no-fehbg --bg-fill "$HOME/pictures/wallpaper.jpg"
|
||||
Reference in New Issue
Block a user