mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Cohesive shell script formatting
- Format all shell scripts using [shfmt] (https://github.com/mvdan/sh). Options used: * `-bn`: binary ops like && and | may start a line * `-sr`: redirect operators will be followed by a space * `-ci`: indent switch cases * `-i 4`: indent 4 spaces * `-s`: simplify the code * `-p`: parse for posix compliance - Add Github action to lint changes to scripts and enforce formatting going forward Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
This commit is contained in:
parent
87c2950039
commit
eed099b954
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
set -C -f -u
|
set -C -f -u
|
||||||
#IFS=$'\n'
|
#IFS=$'\n'
|
||||||
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
|
IFS="$(printf '%b_' '\n')"
|
||||||
|
IFS="${IFS%_}"
|
||||||
|
|
||||||
# ANSI color codes are supported.
|
# ANSI color codes are supported.
|
||||||
# STDIN is disabled, so interactive scripts won't work properly
|
# STDIN is disabled, so interactive scripts won't work properly
|
||||||
@ -17,42 +18,42 @@ IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"
|
|||||||
# 2 | plain text | Display the plain content of the file
|
# 2 | plain text | Display the plain content of the file
|
||||||
|
|
||||||
# Script arguments
|
# Script arguments
|
||||||
FILE_PATH="${1}" # Full path of the highlighted file
|
FILE_PATH="${1}" # Full path of the highlighted file
|
||||||
HEIGHT="${2}"
|
HEIGHT="${2}"
|
||||||
|
|
||||||
#FILE_EXTENSION="${FILE_PATH##*.}"
|
#FILE_EXTENSION="${FILE_PATH##*.}"
|
||||||
#FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]')
|
#FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
|
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
|
||||||
HIGHLIGHT_TABWIDTH=8
|
HIGHLIGHT_TABWIDTH=8
|
||||||
HIGHLIGHT_STYLE='pablo'
|
HIGHLIGHT_STYLE='pablo'
|
||||||
|
|
||||||
|
|
||||||
handle_mime() {
|
handle_mime() {
|
||||||
local mimetype="${1}"
|
local mimetype="${1}"
|
||||||
case "${mimetype}" in
|
case "${mimetype}" in
|
||||||
text/html) w3m -dump "${FILE_PATH}" ;;
|
text/html) w3m -dump "${FILE_PATH}" ;;
|
||||||
text/troff) man ./ "${FILE_PATH}" | col -b ;;
|
text/troff) man ./ "${FILE_PATH}" | col -b ;;
|
||||||
text/* | */xml)
|
text/* | */xml)
|
||||||
if [ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]; then
|
if [ "$(stat --printf='%s' -- "${FILE_PATH}")" -gt "${HIGHLIGHT_SIZE_MAX}" ]; then
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
if [ "$( tput colors )" -ge 256 ]; then
|
if [ "$(tput colors)" -ge 256 ]; then
|
||||||
local highlight_format='xterm256'
|
local highlight_format='xterm256'
|
||||||
else
|
else
|
||||||
local highlight_format='ansi'
|
local highlight_format='ansi'
|
||||||
fi
|
fi
|
||||||
highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
|
highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
|
||||||
--style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" ;;
|
--style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}"
|
||||||
application/zip) atool --list -- "${FILE_PATH}" ;;
|
;;
|
||||||
image/*) chafa --fill=block --symbols=block -c 256 -s 80x"${HEIGHT}" "${FILE_PATH}" || exit 1;;
|
application/zip) atool --list -- "${FILE_PATH}" ;;
|
||||||
video/* | audio/*|application/octet-stream) mediainfo "${FILE_PATH}" || exit 1;;
|
image/*) chafa --fill=block --symbols=block -c 256 -s 80x"${HEIGHT}" "${FILE_PATH}" || exit 1 ;;
|
||||||
|
video/* | audio/* | application/octet-stream) mediainfo "${FILE_PATH}" || exit 1 ;;
|
||||||
*/pdf) pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - ;;
|
*/pdf) pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - ;;
|
||||||
*opendocument*) odt2txt "${FILE_PATH}" ;;
|
*opendocument*) odt2txt "${FILE_PATH}" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
|
MIMETYPE="$(file --dereference --brief --mime-type -- "${FILE_PATH}")"
|
||||||
handle_mime "${MIMETYPE}"
|
handle_mime "${MIMETYPE}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@ -7,44 +7,44 @@
|
|||||||
[ -f "$XINITRC" ] && alias startx="startx $XINITRC"
|
[ -f "$XINITRC" ] && alias startx="startx $XINITRC"
|
||||||
|
|
||||||
# sudo not required for some system commands
|
# sudo not required for some system commands
|
||||||
for x in mount umount sv pacman updatedb su ; do
|
for x in mount umount sv pacman updatedb su; do
|
||||||
alias $x="sudo $x"
|
alias $x="sudo $x"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Verbosity and settings that you pretty much just always are going to want.
|
# Verbosity and settings that you pretty much just always are going to want.
|
||||||
alias \
|
alias \
|
||||||
cp="cp -iv" \
|
cp="cp -iv" \
|
||||||
mv="mv -iv" \
|
mv="mv -iv" \
|
||||||
rm="rm -vI" \
|
rm="rm -vI" \
|
||||||
bc="bc -ql" \
|
bc="bc -ql" \
|
||||||
mkd="mkdir -pv" \
|
mkd="mkdir -pv" \
|
||||||
yt="youtube-dl --add-metadata -i" \
|
yt="youtube-dl --add-metadata -i" \
|
||||||
yta="yt -x -f bestaudio/best" \
|
yta="yt -x -f bestaudio/best" \
|
||||||
ffmpeg="ffmpeg -hide_banner"
|
ffmpeg="ffmpeg -hide_banner"
|
||||||
|
|
||||||
# Colorize commands when possible.
|
# Colorize commands when possible.
|
||||||
alias \
|
alias \
|
||||||
ls="ls -hN --color=auto --group-directories-first" \
|
ls="ls -hN --color=auto --group-directories-first" \
|
||||||
grep="grep --color=auto" \
|
grep="grep --color=auto" \
|
||||||
diff="diff --color=auto" \
|
diff="diff --color=auto" \
|
||||||
ccat="highlight --out-format=ansi"
|
ccat="highlight --out-format=ansi"
|
||||||
|
|
||||||
# These common commands are just too long! Abbreviate them.
|
# These common commands are just too long! Abbreviate them.
|
||||||
alias \
|
alias \
|
||||||
ka="killall" \
|
ka="killall" \
|
||||||
g="git" \
|
g="git" \
|
||||||
trem="transmission-remote" \
|
trem="transmission-remote" \
|
||||||
YT="youtube-viewer" \
|
YT="youtube-viewer" \
|
||||||
sdn="sudo shutdown -h now" \
|
sdn="sudo shutdown -h now" \
|
||||||
e="$EDITOR" \
|
e="$EDITOR" \
|
||||||
v="$EDITOR" \
|
v="$EDITOR" \
|
||||||
p="sudo pacman" \
|
p="sudo pacman" \
|
||||||
xi="sudo xbps-install" \
|
xi="sudo xbps-install" \
|
||||||
xr="sudo xbps-remove -R" \
|
xr="sudo xbps-remove -R" \
|
||||||
xq="xbps-query" \
|
xq="xbps-query" \
|
||||||
z="zathura"
|
z="zathura"
|
||||||
|
|
||||||
alias \
|
alias \
|
||||||
magit="nvim -c MagitOnly" \
|
magit="nvim -c MagitOnly" \
|
||||||
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" \
|
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/zshnameddirrc" \
|
||||||
weath="less -S ${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" \
|
weath="less -S ${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
|
||||||
|
|||||||
@ -1,33 +1,38 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
while read file
|
while read file; do
|
||||||
do
|
case "$1" in
|
||||||
case "$1" in
|
|
||||||
"w") setbg "$file" & ;;
|
"w") setbg "$file" & ;;
|
||||||
"c")
|
"c")
|
||||||
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")"
|
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")"
|
||||||
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
|
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
|
||||||
cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
|
cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
|
||||||
;;
|
;;
|
||||||
"m")
|
"m")
|
||||||
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")"
|
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")"
|
||||||
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
|
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
|
||||||
mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
|
mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
|
||||||
;;
|
;;
|
||||||
"r")
|
"r")
|
||||||
convert -rotate 90 "$file" "$file" ;;
|
convert -rotate 90 "$file" "$file"
|
||||||
"R")
|
;;
|
||||||
convert -rotate -90 "$file" "$file" ;;
|
"R")
|
||||||
"f")
|
convert -rotate -90 "$file" "$file"
|
||||||
convert -flop "$file" "$file" ;;
|
;;
|
||||||
"y")
|
"f")
|
||||||
echo -n "$file" | tr -d '\n' | xclip -selection clipboard &&
|
convert -flop "$file" "$file"
|
||||||
notify-send "$file copied to clipboard" & ;;
|
;;
|
||||||
"Y")
|
"y")
|
||||||
readlink -f "$file" | tr -d '\n' | xclip -selection clipboard &&
|
echo -n "$file" | tr -d '\n' | xclip -selection clipboard \
|
||||||
notify-send "$(readlink -f "$file") copied to clipboard" & ;;
|
&& notify-send "$file copied to clipboard" &
|
||||||
"d")
|
;;
|
||||||
[ "$(printf "No\\nYes" | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted." ;;
|
"Y")
|
||||||
"g") ifinstalled gimp && setsid -f gimp "$file" ;;
|
readlink -f "$file" | tr -d '\n' | xclip -selection clipboard \
|
||||||
"i") notify-send "File information" "$(mediainfo "$file")" ;;
|
&& notify-send "$(readlink -f "$file") copied to clipboard" &
|
||||||
esac
|
;;
|
||||||
|
"d")
|
||||||
|
[ "$(printf 'No\nYes' | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted."
|
||||||
|
;;
|
||||||
|
"g") ifinstalled gimp && setsid -f gimp "$file" ;;
|
||||||
|
"i") notify-send "File information" "$(mediainfo "$file")" ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|||||||
@ -2,26 +2,26 @@
|
|||||||
|
|
||||||
source "${HOME}/.cache/wal/colors.sh"
|
source "${HOME}/.cache/wal/colors.sh"
|
||||||
|
|
||||||
mkdir -p "${HOME}/.config/dunst"
|
mkdir -p "${HOME}/.config/dunst"
|
||||||
mkdir -p "${HOME}/.config/zathura"
|
mkdir -p "${HOME}/.config/zathura"
|
||||||
ln -sf "${HOME}/.cache/wal/dunstrc" "${HOME}/.config/dunst/dunstrc"
|
ln -sf "${HOME}/.cache/wal/dunstrc" "${HOME}/.config/dunst/dunstrc"
|
||||||
ln -sf "${HOME}/.cache/wal/zathurarc" "${HOME}/.config/zathura/zathurarc"
|
ln -sf "${HOME}/.cache/wal/zathurarc" "${HOME}/.config/zathura/zathurarc"
|
||||||
|
|
||||||
fix_sequences() {
|
fix_sequences() {
|
||||||
e=$'\e'
|
e=$'\e'
|
||||||
sequences=$(cat)
|
sequences=$(cat)
|
||||||
foreground_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]10[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
|
foreground_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]10[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
|
||||||
background_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]11[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
|
background_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]11[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
|
||||||
cursor_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]12[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
|
cursor_color="$(echo -e "${sequences}\c" | grep --color=never -Eo "${e}]12[^${e}\\\\]*?${e}\\\\" | grep --color=never -Eo "#[0-9A-Fa-f]{6}")"
|
||||||
|
|
||||||
for term in /dev/pts/{0..9}*
|
for term in /dev/pts/{0..9}*; do
|
||||||
do
|
echo -e "\e]4;256;${cursor_color}\a\c" > "${term}" 2> /dev/null
|
||||||
echo -e "\e]4;256;${cursor_color}\a\c" > "${term}" 2>/dev/null
|
echo -e "\e]4;258;${background_color}\a\c" > "${term}" 2> /dev/null
|
||||||
echo -e "\e]4;258;${background_color}\a\c" > "${term}" 2>/dev/null
|
echo -e "\e]4;259;${foreground_color}\a\c" > "${term}" 2> /dev/null
|
||||||
echo -e "\e]4;259;${foreground_color}\a\c" > "${term}" 2>/dev/null
|
done
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_sequences <"${HOME}/.cache/wal/sequences"
|
fix_sequences < "${HOME}/.cache/wal/sequences"
|
||||||
|
|
||||||
pkill dunst; dunst &
|
pkill dunst
|
||||||
|
dunst &
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
# I source them here with the line below.
|
# I source them here with the line below.
|
||||||
|
|
||||||
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile" ]; then
|
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile" ]; then
|
||||||
. "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile"
|
. "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile"
|
||||||
else
|
else
|
||||||
. "$HOME/.xprofile"
|
. "$HOME/.xprofile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh-agent dwm
|
ssh-agent dwm
|
||||||
|
|||||||
@ -3,18 +3,18 @@
|
|||||||
# This file runs when a DM logs you into a graphical session.
|
# This file runs when a DM logs you into a graphical session.
|
||||||
# If you use startx/xinit like a Chad, this file will also be sourced.
|
# If you use startx/xinit like a Chad, this file will also be sourced.
|
||||||
|
|
||||||
setbg & # set the background with the `setbg` script
|
setbg & # set the background with the `setbg` script
|
||||||
#xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & # Uncomment to use Xresources colors/settings on startup
|
#xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & # Uncomment to use Xresources colors/settings on startup
|
||||||
mpd & # music player daemon-you might prefer it as a service though
|
mpd & # music player daemon-you might prefer it as a service though
|
||||||
remaps & # run the remaps script, switching caps/esc and more; check it for more info
|
remaps & # run the remaps script, switching caps/esc and more; check it for more info
|
||||||
xcompmgr & # xcompmgr for transparency
|
xcompmgr & # xcompmgr for transparency
|
||||||
dunst & # dunst for notifications
|
dunst & # dunst for notifications
|
||||||
xset r rate 300 50 & # Speed xrate up
|
xset r rate 300 50 & # Speed xrate up
|
||||||
unclutter & # Remove mouse when idle
|
unclutter & # Remove mouse when idle
|
||||||
|
|
||||||
# This line autostarts an instance of Pulseaudio that does not exit on idle.
|
# This line autostarts an instance of Pulseaudio that does not exit on idle.
|
||||||
# This is "necessary" on Artix due to a current bug between PA and
|
# This is "necessary" on Artix due to a current bug between PA and
|
||||||
# Chromium-based browsers where they fail to start PA and use dummy output.
|
# Chromium-based browsers where they fail to start PA and use dummy output.
|
||||||
pidof -s runit &&
|
pidof -s runit \
|
||||||
! pidof -s pulseaudio >/dev/null 2>&1 &&
|
&& ! pidof -s pulseaudio > /dev/null 2>&1 \
|
||||||
setsid -f pulseaudio --start --exit-idle-time=-1 >/dev/null 2>&1
|
&& setsid -f pulseaudio --start --exit-idle-time=-1 > /dev/null 2>&1
|
||||||
|
|||||||
38
.github/workflows/linter.yml
vendored
Normal file
38
.github/workflows/linter.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: shfmt-linter
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
|
- name: update system
|
||||||
|
run: |
|
||||||
|
sudo apt-get upgrade --install-suggests --yes
|
||||||
|
|
||||||
|
- name: install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get install git \
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: apply shfmt fixes
|
||||||
|
run: |
|
||||||
|
docker run --volume "$PWD":/mnt \
|
||||||
|
--rm \
|
||||||
|
mvdan/shfmt -bn -ci -d -i 4 -p -s -sr -w /mnt
|
||||||
|
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: (maint) apply shfmt formatting
|
||||||
|
commit_options: '--cleanup=default --no-verify --signoff'
|
||||||
|
push_options: '--force'
|
||||||
|
skip_dirty_check: false
|
||||||
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
|
# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
|
||||||
|
|
||||||
[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
|
[ ! -f "$2" ] && printf 'The first file should be the audio, the second should be the timecodes.\n' && exit
|
||||||
|
|
||||||
echo "Enter the album/book title:"; read -r booktitle
|
echo "Enter the album/book title:"
|
||||||
|
read -r booktitle
|
||||||
|
|
||||||
echo "Enter the artist/author:"; read -r author
|
echo "Enter the artist/author:"
|
||||||
|
read -r author
|
||||||
|
|
||||||
echo "Enter the publication year:"; read -r year
|
echo "Enter the publication year:"
|
||||||
|
read -r year
|
||||||
|
|
||||||
inputaudio="$1"
|
inputaudio="$1"
|
||||||
|
|
||||||
@ -24,23 +27,22 @@ ext="opus"
|
|||||||
# Get the total number of tracks from the number of lines.
|
# Get the total number of tracks from the number of lines.
|
||||||
total="$(wc -l < "$2")"
|
total="$(wc -l < "$2")"
|
||||||
|
|
||||||
while read -r x;
|
while read -r x; do
|
||||||
do
|
end="$(echo "$x" | cut -d' ' -f1)"
|
||||||
end="$(echo "$x" | cut -d' ' -f1)"
|
|
||||||
|
|
||||||
[ -n "$start" ] &&
|
[ -n "$start" ] \
|
||||||
echo "From $start to $end; $track $title"
|
&& echo "From $start to $end; $track $title"
|
||||||
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
||||||
[ -n "$start" ] && echo "Splitting \"$title\"..." &&
|
[ -n "$start" ] && echo "Splitting \"$title\"..." \
|
||||||
ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn -c copy "$file" &&
|
&& ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn -c copy "$file" \
|
||||||
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
|
&& echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
|
||||||
title="$(echo "$x" | cut -d' ' -f 2-)"
|
title="$(echo "$x" | cut -d' ' -f 2-)"
|
||||||
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
|
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
|
||||||
track="$((track+1))"
|
track="$((track + 1))"
|
||||||
start="$end"
|
start="$end"
|
||||||
done < "$2"
|
done < "$2"
|
||||||
# The last track must be done outside the loop.
|
# The last track must be done outside the loop.
|
||||||
echo "From $start to the end: $title"
|
echo "From $start to the end: $title"
|
||||||
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
|
||||||
echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn -c copy "$file" &&
|
echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn -c copy "$file" \
|
||||||
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
|
&& echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
|
||||||
|
|||||||
@ -16,42 +16,42 @@ ext="${file##*.}"
|
|||||||
|
|
||||||
cd "$dir" || exit 1
|
cd "$dir" || exit 1
|
||||||
|
|
||||||
textype() { \
|
textype() {
|
||||||
command="pdflatex"
|
command="pdflatex"
|
||||||
( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
|
(head -n5 "$file" | grep -qi 'xelatex') && command="xelatex"
|
||||||
$command --output-directory="$dir" "$base" &&
|
$command --output-directory="$dir" "$base" \
|
||||||
grep -qi addbibresource "$file" &&
|
&& grep -qi addbibresource "$file" \
|
||||||
biber --input-directory "$dir" "$base" &&
|
&& biber --input-directory "$dir" "$base" \
|
||||||
$command --output-directory="$dir" "$base" &&
|
&& $command --output-directory="$dir" "$base" \
|
||||||
$command --output-directory="$dir" "$base"
|
&& $command --output-directory="$dir" "$base"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$ext" in
|
case "$ext" in
|
||||||
# Try to keep these cases in alphabetical order.
|
# Try to keep these cases in alphabetical order.
|
||||||
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
|
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
|
||||||
c) cc "$file" -o "$base" && "$base" ;;
|
c) cc "$file" -o "$base" && "$base" ;;
|
||||||
cpp) g++ "$file" -o "$base" && "$base" ;;
|
cpp) g++ "$file" -o "$base" && "$base" ;;
|
||||||
cs) mcs "$file" && mono "$base".exe ;;
|
cs) mcs "$file" && mono "$base".exe ;;
|
||||||
go) go run "$file" ;;
|
go) go run "$file" ;;
|
||||||
h) sudo make install ;;
|
h) sudo make install ;;
|
||||||
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
|
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
|
||||||
m) octave "$file" ;;
|
m) octave "$file" ;;
|
||||||
md) if [ -x "$(command -v lowdown)" ]; then
|
md) if [ -x "$(command -v lowdown)" ]; then
|
||||||
lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
|
lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
|
||||||
elif [ -x "$(command -v groffdown)" ]; then
|
elif [ -x "$(command -v groffdown)" ]; then
|
||||||
groffdown -i "$file" | groff > "$base.pdf"
|
groffdown -i "$file" | groff > "$base.pdf"
|
||||||
else
|
else
|
||||||
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
|
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
|
||||||
fi ; ;;
|
fi ;;
|
||||||
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
|
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 ;;
|
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 ;;
|
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
|
||||||
py) python "$file" ;;
|
py) python "$file" ;;
|
||||||
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
|
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
|
||||||
rs) cargo build ;;
|
rs) cargo build ;;
|
||||||
sass) sassc -a "$file" "$base.css" ;;
|
sass) sassc -a "$file" "$base.css" ;;
|
||||||
scad) openscad -o "$base".stl "$file" ;;
|
scad) openscad -o "$base".stl "$file" ;;
|
||||||
sent) setsid -f sent "$file" 2>/dev/null ;;
|
sent) setsid -f sent "$file" 2> /dev/null ;;
|
||||||
tex) textype "$file" ;;
|
tex) textype "$file" ;;
|
||||||
*) head -n1 "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
*) head -n1 "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -11,9 +11,8 @@ 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."
|
Check your internet connection, if pacman is already running, or run update manually to see errors."
|
||||||
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
||||||
|
|
||||||
if pacman -Qu | grep -v "\[ignored\]"
|
if pacman -Qu | grep -v "\[ignored\]"; then
|
||||||
then
|
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
|
||||||
notify-send "🎁 Repository Sync" "Updates available. Click statusbar icon (📦) for update."
|
|
||||||
else
|
else
|
||||||
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
|
notify-send "📦 Repository Sync" "Sync complete. No new packages for update."
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -3,4 +3,4 @@
|
|||||||
# Toggles all cronjobs off/on.
|
# Toggles all cronjobs off/on.
|
||||||
# Stores disabled crontabs in ~/.consaved until restored.
|
# Stores disabled crontabs in ~/.consaved 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.")
|
||||||
|
|||||||
@ -6,17 +6,17 @@
|
|||||||
|
|
||||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||||
|
|
||||||
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
|
mirror=$(printf 'no\nyes' | dmenu -i -p "Mirror displays?")
|
||||||
# Mirror displays using native resolution of external display and a scaled
|
# Mirror displays using native resolution of external display and a scaled
|
||||||
# version for the internal display
|
# version for the internal display
|
||||||
if [ "$mirror" = "yes" ]; then
|
if [ "$mirror" = "yes" ]; then
|
||||||
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
|
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
|
||||||
internal=$(echo "$screens" | grep -v "$external")
|
internal=$(echo "$screens" | grep -v "$external")
|
||||||
|
|
||||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" \
|
||||||
tail -n 1 | awk '{print $1}')
|
| tail -n 1 | awk '{print $1}')
|
||||||
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
|
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" \
|
||||||
tail -n 1 | awk '{print $1}')
|
| tail -n 1 | awk '{print $1}')
|
||||||
|
|
||||||
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
||||||
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
|
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
|
||||||
@ -33,34 +33,38 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
|
|||||||
|
|
||||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||||
secondary=$(echo "$screens" | grep -v "$primary")
|
secondary=$(echo "$screens" | grep -v "$primary")
|
||||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
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
|
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||||
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary 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?")
|
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:")
|
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
|
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.
|
multimon() { # Multi-monitor handler.
|
||||||
case "$(echo "$screens" | wc -l)" in
|
case "$(echo "$screens" | wc -l)" in
|
||||||
2) twoscreen ;;
|
2) twoscreen ;;
|
||||||
*) morescreen ;;
|
*) morescreen ;;
|
||||||
esac ;}
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
onescreen() { # If only one output available or chosen.
|
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.
|
postrun() { # Stuff to run to clean up.
|
||||||
setbg # Fix background if screen size/arangement has changed.
|
setbg # Fix background if screen size/arangement has changed.
|
||||||
remaps # Re-remap keys if keyboard added (for laptop bases)
|
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
|
{
|
||||||
}
|
killall dunst
|
||||||
|
setsid -f dunst
|
||||||
|
} > /dev/null 2>&1 # Restart dunst to ensure proper location on screen
|
||||||
|
}
|
||||||
|
|
||||||
# Get all possible displays
|
# Get all possible displays
|
||||||
allposs=$(xrandr -q | grep "connected")
|
allposs=$(xrandr -q | grep "connected")
|
||||||
@ -69,15 +73,23 @@ allposs=$(xrandr -q | grep "connected")
|
|||||||
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||||
|
|
||||||
# If there's only one screen
|
# If there's only one screen
|
||||||
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
|
[ "$(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:
|
# Get user choice including multi-monitor and manual selection:
|
||||||
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
|
chosen=$(printf '%s\nmulti-monitor\nmanual selection' "$screens" | dmenu -i -p "Select display arangement:") \
|
||||||
case "$chosen" in
|
&& case "$chosen" in
|
||||||
"manual selection") arandr ; exit ;;
|
"manual selection")
|
||||||
"multi-monitor") multimon ;;
|
arandr
|
||||||
*) onescreen "$chosen" ;;
|
exit
|
||||||
esac
|
;;
|
||||||
|
"multi-monitor") multimon ;;
|
||||||
|
*) onescreen "$chosen" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
postrun
|
postrun
|
||||||
|
|||||||
@ -4,18 +4,21 @@
|
|||||||
# some choice programs to use to open it.
|
# some choice programs to use to open it.
|
||||||
feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}"
|
feed="${1:-$(printf "%s" | dmenu -p 'Paste URL or file path')}"
|
||||||
|
|
||||||
case "$(printf "Copy URL\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dl\\nqueue yt-dl audio" | dmenu -i -p "Open it with?")" in
|
case "$(printf 'Copy URL\nsxiv\nsetbg\nPDF\nbrowser\nlynx\nvim\nmpv\nmpv loop\nmpv float\nqueue download\nqueue yt-dl\nqueue yt-dl audio' | dmenu -i -p "Open it with?")" in
|
||||||
"copy url") echo "$feed" | xclip -selection clipboard ;;
|
"copy url") echo "$feed" | xclip -selection clipboard ;;
|
||||||
mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;;
|
mpv) setsid -f mpv -quiet "$feed" > /dev/null 2>&1 ;;
|
||||||
"mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;;
|
"mpv loop") setsid -f mpv -quiet --loop "$feed" > /dev/null 2>&1 ;;
|
||||||
"mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;;
|
"mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" > /dev/null 2>&1 ;;
|
||||||
"queue yt-dl") qndl "$feed" >/dev/null 2>&1 ;;
|
"queue yt-dl") qndl "$feed" > /dev/null 2>&1 ;;
|
||||||
"queue yt-dl audio") qndl "$feed" 'youtube-dl --add-metadata -icx -f bestaudio/best' >/dev/null 2>&1 ;;
|
"queue yt-dl audio") qndl "$feed" 'youtube-dl --add-metadata -icx -f bestaudio/best' > /dev/null 2>&1 ;;
|
||||||
"queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;;
|
"queue download") qndl "$feed" 'curl -LO' > /dev/null 2>&1 ;;
|
||||||
PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;;
|
PDF) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 ;;
|
||||||
sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;;
|
sxiv) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 ;;
|
||||||
vim) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;;
|
vim) curl -sL "$feed" > "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 ;;
|
||||||
setbg) curl -L "$feed" > $XDG_CACHE_HOME/pic ; xwallpaper --zoom $XDG_CACHE_HOME/pic >/dev/null 2>&1 ;;
|
setbg)
|
||||||
browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;;
|
curl -L "$feed" > $XDG_CACHE_HOME/pic
|
||||||
lynx) lynx "$feed" >/dev/null 2>&1 ;;
|
xwallpaper --zoom $XDG_CACHE_HOME/pic > /dev/null 2>&1
|
||||||
|
;;
|
||||||
|
browser) setsid -f "$BROWSER" "$feed" > /dev/null 2>&1 ;;
|
||||||
|
lynx) lynx "$feed" > /dev/null 2>&1 ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -5,63 +5,68 @@
|
|||||||
# be prompted to give a mountpoint from already existsing directories. If you
|
# be prompted to give a mountpoint from already existsing directories. If you
|
||||||
# input a novel directory, it will prompt you to create that directory.
|
# input a novel directory, it will prompt you to create that directory.
|
||||||
|
|
||||||
getmount() { \
|
getmount() {
|
||||||
[ -z "$chosen" ] && exit 1
|
[ -z "$chosen" ] && exit 1
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
mp="$(find $1 2> /dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
||||||
[ "$mp" = "" ] && exit 1
|
[ "$mp" = "" ] && exit 1
|
||||||
if [ ! -d "$mp" ]; then
|
if [ ! -d "$mp" ]; then
|
||||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
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")
|
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mountusb() { \
|
mountusb() {
|
||||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
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}')
|
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"
|
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
||||||
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||||
case "$partitiontype" in
|
case "$partitiontype" in
|
||||||
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
"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)";;
|
"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
|
sudo -A mount "$chosen" "$mp"
|
||||||
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
user="$(whoami)"
|
||||||
}
|
ug="$(groups | awk '{print $1}')"
|
||||||
|
sudo -A chown "$user":"$ug" "$mp"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||||
|
}
|
||||||
|
|
||||||
mountandroid() { \
|
mountandroid() {
|
||||||
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
|
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | cut -d : -f 1)"
|
chosen="$(echo "$chosen" | cut -d : -f 1)"
|
||||||
getmount "$HOME -maxdepth 3 -type d"
|
getmount "$HOME -maxdepth 3 -type d"
|
||||||
simple-mtpfs --device "$chosen" "$mp"
|
simple-mtpfs --device "$chosen" "$mp"
|
||||||
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
|
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"
|
simple-mtpfs --device "$chosen" "$mp"
|
||||||
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||||
}
|
}
|
||||||
|
|
||||||
asktype() { \
|
asktype() {
|
||||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
|
choice="$(printf 'USB\nAndroid' | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
|
||||||
case $choice in
|
case $choice in
|
||||||
USB) mountusb ;;
|
USB) mountusb ;;
|
||||||
Android) mountandroid ;;
|
Android) mountandroid ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
anddrives=$(simple-mtpfs -l 2> /dev/null)
|
||||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
||||||
|
|
||||||
if [ -z "$usbdrives" ]; then
|
if [ -z "$usbdrives" ]; then
|
||||||
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||||
echo "Android device(s) detected."
|
echo "Android device(s) detected."
|
||||||
mountandroid
|
mountandroid
|
||||||
else
|
else
|
||||||
if [ -z "$anddrives" ]; then
|
if [ -z "$anddrives" ]; then
|
||||||
echo "USB drive(s) detected."
|
echo "USB drive(s) detected."
|
||||||
mountusb
|
mountusb
|
||||||
else
|
else
|
||||||
echo "Mountable USB drive(s) and Android device(s) detected."
|
echo "Mountable USB drive(s) and Android device(s) detected."
|
||||||
asktype
|
asktype
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -11,9 +11,10 @@ share=$(smbclient -L "$srvname" -N | grep Disk | awk '{print $1}' | dmenu -i -p
|
|||||||
share2mnt=//"$srvname".local/"$share"
|
share2mnt=//"$srvname".local/"$share"
|
||||||
|
|
||||||
sharemount() {
|
sharemount() {
|
||||||
mounted=$(mount -v | grep "$share2mnt") || ([ ! -d /mnt/"$share" ] && sudo mkdir /mnt/"$share")
|
mounted=$(mount -v | grep "$share2mnt") || ([ ! -d /mnt/"$share" ] && sudo mkdir /mnt/"$share")
|
||||||
[ -z "$mounted" ] && sudo mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0
|
[ -z "$mounted" ] && sudo mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0
|
||||||
notify-send "Netshare $share already mounted"; exit 1
|
notify-send "Netshare $share already mounted"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
sharemount
|
sharemount
|
||||||
|
|||||||
@ -9,115 +9,116 @@
|
|||||||
#
|
#
|
||||||
# If there is already a running instance, user will be prompted to end it.
|
# If there is already a running instance, user will be prompted to end it.
|
||||||
|
|
||||||
updateicon() { \
|
updateicon() {
|
||||||
echo "$1" > /tmp/recordingicon
|
echo "$1" > /tmp/recordingicon
|
||||||
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
||||||
}
|
}
|
||||||
|
|
||||||
killrecording() {
|
killrecording() {
|
||||||
recpid="$(cat /tmp/recordingpid)"
|
recpid="$(cat /tmp/recordingpid)"
|
||||||
# kill with SIGTERM, allowing finishing touches.
|
# kill with SIGTERM, allowing finishing touches.
|
||||||
kill -15 "$recpid"
|
kill -15 "$recpid"
|
||||||
rm -f /tmp/recordingpid
|
rm -f /tmp/recordingpid
|
||||||
updateicon ""
|
updateicon ""
|
||||||
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}"
|
||||||
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
|
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
|
||||||
sleep 3
|
sleep 3
|
||||||
kill -9 "$recpid"
|
kill -9 "$recpid"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
screencast() { \
|
screencast() {
|
||||||
ffmpeg -y \
|
ffmpeg -y \
|
||||||
-f x11grab \
|
-f x11grab \
|
||||||
-framerate 60 \
|
-framerate 60 \
|
||||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||||
-i "$DISPLAY" \
|
-i "$DISPLAY" \
|
||||||
-f alsa -i default \
|
-f alsa -i default \
|
||||||
-r 30 \
|
-r 30 \
|
||||||
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
|
-c:v h264 -crf 0 -preset ultrafast -c:a aac \
|
||||||
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
|
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" &
|
||||||
echo $! > /tmp/recordingpid
|
echo $! > /tmp/recordingpid
|
||||||
updateicon "⏺️🎙️"
|
updateicon "⏺️🎙️"
|
||||||
}
|
}
|
||||||
|
|
||||||
video() { ffmpeg \
|
video() {
|
||||||
-f x11grab \
|
ffmpeg \
|
||||||
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
-f x11grab \
|
||||||
-i "$DISPLAY" \
|
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
|
||||||
-c:v libx264 -qp 0 -r 30 \
|
-i "$DISPLAY" \
|
||||||
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
-c:v libx264 -qp 0 -r 30 \
|
||||||
echo $! > /tmp/recordingpid
|
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||||
updateicon "⏺️"
|
echo $! > /tmp/recordingpid
|
||||||
}
|
updateicon "⏺️"
|
||||||
|
}
|
||||||
|
|
||||||
webcamhidef() { ffmpeg \
|
webcamhidef() {
|
||||||
-f v4l2 \
|
ffmpeg \
|
||||||
-i /dev/video0 \
|
-f v4l2 \
|
||||||
-video_size 1920x1080 \
|
-i /dev/video0 \
|
||||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
-video_size 1920x1080 \
|
||||||
echo $! > /tmp/recordingpid
|
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||||
updateicon "🎥"
|
echo $! > /tmp/recordingpid
|
||||||
}
|
updateicon "🎥"
|
||||||
|
}
|
||||||
|
|
||||||
webcam() { ffmpeg \
|
webcam() {
|
||||||
-f v4l2 \
|
ffmpeg \
|
||||||
-i /dev/video0 \
|
-f v4l2 \
|
||||||
-video_size 640x480 \
|
-i /dev/video0 \
|
||||||
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
-video_size 640x480 \
|
||||||
echo $! > /tmp/recordingpid
|
"$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||||
updateicon "🎥"
|
echo $! > /tmp/recordingpid
|
||||||
}
|
updateicon "🎥"
|
||||||
|
}
|
||||||
|
|
||||||
|
audio() {
|
||||||
|
ffmpeg \
|
||||||
|
-f alsa -i default \
|
||||||
|
-c:a flac \
|
||||||
|
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
|
||||||
|
echo $! > /tmp/recordingpid
|
||||||
|
updateicon "🎙️"
|
||||||
|
}
|
||||||
|
|
||||||
audio() { \
|
askrecording() {
|
||||||
ffmpeg \
|
choice=$(printf 'screencast\nvideo\nvideo selected\naudio\nwebcam\nwebcam (hi-def)' | dmenu -i -p "Select recording style:")
|
||||||
-f alsa -i default \
|
case "$choice" in
|
||||||
-c:a flac \
|
screencast) screencast ;;
|
||||||
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
|
audio) audio ;;
|
||||||
echo $! > /tmp/recordingpid
|
video) video ;;
|
||||||
updateicon "🎙️"
|
*selected) videoselected ;;
|
||||||
}
|
webcam) webcam ;;
|
||||||
|
"webcam (hi-def)") webcamhidef ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
askrecording() { \
|
asktoend() {
|
||||||
choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:")
|
response=$(printf 'No\nYes' | dmenu -i -p "Recording still active. End recording?") \
|
||||||
case "$choice" in
|
&& [ "$response" = "Yes" ] && killrecording
|
||||||
screencast) screencast;;
|
}
|
||||||
audio) audio;;
|
|
||||||
video) video;;
|
|
||||||
*selected) videoselected;;
|
|
||||||
webcam) webcam;;
|
|
||||||
"webcam (hi-def)") webcamhidef;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
asktoend() { \
|
videoselected() {
|
||||||
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
slop -f "%x %y %w %h" > /tmp/slop
|
||||||
[ "$response" = "Yes" ] && killrecording
|
read -r X Y W H < /tmp/slop
|
||||||
}
|
rm /tmp/slop
|
||||||
|
|
||||||
videoselected()
|
ffmpeg \
|
||||||
{
|
-f x11grab \
|
||||||
slop -f "%x %y %w %h" > /tmp/slop
|
-framerate 60 \
|
||||||
read -r X Y W H < /tmp/slop
|
-video_size "$W"x"$H" \
|
||||||
rm /tmp/slop
|
-i :0.0+"$X,$Y" \
|
||||||
|
-c:v libx264 -qp 0 -r 30 \
|
||||||
ffmpeg \
|
"$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" &
|
||||||
-f x11grab \
|
echo $! > /tmp/recordingpid
|
||||||
-framerate 60 \
|
updateicon "⏺️"
|
||||||
-video_size "$W"x"$H" \
|
|
||||||
-i :0.0+"$X,$Y" \
|
|
||||||
-c:v libx264 -qp 0 -r 30 \
|
|
||||||
"$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" &
|
|
||||||
echo $! > /tmp/recordingpid
|
|
||||||
updateicon "⏺️"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
screencast) screencast;;
|
screencast) screencast ;;
|
||||||
audio) audio;;
|
audio) audio ;;
|
||||||
video) video;;
|
video) video ;;
|
||||||
*selected) videoselected;;
|
*selected) videoselected ;;
|
||||||
kill) killrecording;;
|
kill) killrecording ;;
|
||||||
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
|
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -5,40 +5,39 @@
|
|||||||
# Drives mounted at /, /boot and /home will not be options to unmount.
|
# Drives mounted at /, /boot and /home will not be options to unmount.
|
||||||
|
|
||||||
unmountusb() {
|
unmountusb() {
|
||||||
[ -z "$drives" ] && exit
|
[ -z "$drives" ] && exit
|
||||||
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
||||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||||
[ -z "$chosen" ] && exit
|
[ -z "$chosen" ] && exit
|
||||||
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||||
}
|
}
|
||||||
|
|
||||||
unmountandroid() { \
|
unmountandroid() {
|
||||||
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
||||||
[ -z "$chosen" ] && exit
|
[ -z "$chosen" ] && exit
|
||||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||||
}
|
}
|
||||||
|
|
||||||
asktype() { \
|
asktype() {
|
||||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
|
choice="$(printf 'USB\nAndroid' | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
USB) unmountusb ;;
|
USB) unmountusb ;;
|
||||||
Android) unmountandroid ;;
|
Android) unmountandroid ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
||||||
|
|
||||||
if ! grep simple-mtpfs /etc/mtab; then
|
if ! grep simple-mtpfs /etc/mtab; then
|
||||||
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
||||||
echo "Unmountable USB drive detected."
|
echo "Unmountable USB drive detected."
|
||||||
unmountusb
|
unmountusb
|
||||||
else
|
else
|
||||||
if [ -z "$drives" ]
|
if [ -z "$drives" ]; then
|
||||||
then
|
echo "Unmountable Android device detected."
|
||||||
echo "Unmountable Android device detected."
|
unmountandroid
|
||||||
unmountandroid
|
else
|
||||||
else
|
echo "Unmountable USB drive(s) and Android device(s) detected."
|
||||||
echo "Unmountable USB drive(s) and Android device(s) detected."
|
asktype
|
||||||
asktype
|
fi
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -11,8 +11,8 @@ chosen=$(cut -d ';' -f1 ~/.local/share/larbs/emoji | dmenu -i -l 30 | sed "s/ .*
|
|||||||
# If you run this command with an argument, it will automatically insert the
|
# If you run this command with an argument, it will automatically insert the
|
||||||
# character. Otherwise, show a message that the emoji has been copied.
|
# character. Otherwise, show a message that the emoji has been copied.
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
xdotool type "$chosen"
|
xdotool type "$chosen"
|
||||||
else
|
else
|
||||||
printf "$chosen" | xclip -selection clipboard
|
printf "$chosen" | xclip -selection clipboard
|
||||||
notify-send "'$chosen' copied to clipboard." &
|
notify-send "'$chosen' copied to clipboard." &
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -7,39 +7,39 @@
|
|||||||
# Behavior with `-c` option: Extract contents into current directory
|
# Behavior with `-c` option: Extract contents into current directory
|
||||||
|
|
||||||
while getopts "hc" o; do case "${o}" in
|
while getopts "hc" o; do case "${o}" in
|
||||||
c) extracthere="True" ;;
|
c) extracthere="True" ;;
|
||||||
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit 1 ;;
|
*) printf 'Options:\n -c: Extract archive into current directory rather than a new one.\n' && exit 1 ;;
|
||||||
esac done
|
esac; done
|
||||||
|
|
||||||
if [ -z "$extracthere" ]; then
|
if [ -z "$extracthere" ]; then
|
||||||
archive="$(readlink -f "$*")" &&
|
archive="$(readlink -f "$*")" \
|
||||||
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
|
&& directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" \
|
||||||
mkdir -p "$directory" &&
|
&& mkdir -p "$directory" \
|
||||||
cd "$directory" || exit 1
|
&& cd "$directory" || exit 1
|
||||||
else
|
else
|
||||||
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2>/dev/null)"
|
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)" 2> /dev/null)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$archive" ] && printf "Give archive to extract as argument.\\n" && exit 1
|
[ -z "$archive" ] && printf 'Give archive to extract as argument.\n' && exit 1
|
||||||
|
|
||||||
if [ -f "$archive" ] ; then
|
if [ -f "$archive" ]; then
|
||||||
case "$archive" in
|
case "$archive" in
|
||||||
*.tar.bz2|*.tbz2) tar xvjf "$archive" ;;
|
*.tar.bz2 | *.tbz2) tar xvjf "$archive" ;;
|
||||||
*.tar.xz) tar -xf "$archive" ;;
|
*.tar.xz) tar -xf "$archive" ;;
|
||||||
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
|
*.tar.gz | *.tgz) tar xvzf "$archive" ;;
|
||||||
*.tar.zst) tar -I zstd -xf "$archive" ;;
|
*.tar.zst) tar -I zstd -xf "$archive" ;;
|
||||||
*.lzma) unlzma "$archive" ;;
|
*.lzma) unlzma "$archive" ;;
|
||||||
*.bz2) bunzip2 "$archive" ;;
|
*.bz2) bunzip2 "$archive" ;;
|
||||||
*.rar) unrar x -ad "$archive" ;;
|
*.rar) unrar x -ad "$archive" ;;
|
||||||
*.gz) gunzip "$archive" ;;
|
*.gz) gunzip "$archive" ;;
|
||||||
*.tar) tar xvf "$archive" ;;
|
*.tar) tar xvf "$archive" ;;
|
||||||
*.zip) unzip "$archive" ;;
|
*.zip) unzip "$archive" ;;
|
||||||
*.Z) uncompress "$archive" ;;
|
*.Z) uncompress "$archive" ;;
|
||||||
*.7z) 7z x "$archive" ;;
|
*.7z) 7z x "$archive" ;;
|
||||||
*.xz) unxz "$archive" ;;
|
*.xz) unxz "$archive" ;;
|
||||||
*.exe) cabextract "$archive" ;;
|
*.exe) cabextract "$archive" ;;
|
||||||
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
|
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
printf "File \"%s\" not found.\\n" "$archive"
|
printf 'File "%s" not found.\n' "$archive"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
|
[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
|
||||||
|
|
||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
# Try to get DOI from pdfinfo or pdftotext output.
|
# Try to get DOI from pdfinfo or pdftotext output.
|
||||||
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
|
doi=$(pdfinfo "$1" | grep -io "doi:.*") \
|
||||||
doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) ||
|
|| doi=$(pdftotext "$1" - 2> /dev/null | grep -io "doi:.*" -m 1) \
|
||||||
exit 1
|
|| exit 1
|
||||||
else
|
else
|
||||||
doi="$1"
|
doi="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check crossref.org for the bib citation.
|
# Check crossref.org for the bib citation.
|
||||||
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
|
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w '\n'
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cat "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys/"$1" 2>/dev/null && exit
|
cat "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys/"$1" 2> /dev/null && exit
|
||||||
echo "Run command with one of the following arguments for info about that program:"
|
echo "Run command with one of the following arguments for info about that program:"
|
||||||
ls "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys
|
ls "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
# it informs the user that they need that command to continue. This is used in
|
# it informs the user that they need that command to continue. This is used in
|
||||||
# various other scripts for clarity's sake.
|
# various other scripts for clarity's sake.
|
||||||
|
|
||||||
for x in "$@";do
|
for x in "$@"; do
|
||||||
pacman -Qq "$x" >/dev/null 2>&1 ||
|
pacman -Qq "$x" > /dev/null 2>&1 \
|
||||||
{ notify-send "📦 $x" "must be installed for this function." && exit 1 ;}
|
|| { notify-send "📦 $x" "must be installed for this function." && exit 1; }
|
||||||
done
|
done
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# Reads file names from stdin and selects them in lf.
|
# Reads file names from stdin and selects them in lf.
|
||||||
|
|
||||||
while read -r file; do
|
while read -r file; do
|
||||||
[ -z "$file" ] && continue
|
[ -z "$file" ] && continue
|
||||||
lf -remote "send select \"$file\""
|
lf -remote "send select \"$file\""
|
||||||
lf -remote "send toggle"
|
lf -remote "send toggle"
|
||||||
done
|
done
|
||||||
|
|||||||
@ -7,17 +7,25 @@
|
|||||||
# otherwise it opens link in browser.
|
# otherwise it opens link in browser.
|
||||||
|
|
||||||
# If no url given. Opens browser. For using script as $BROWSER.
|
# If no url given. Opens browser. For using script as $BROWSER.
|
||||||
[ -z "$1" ] && { "$BROWSER"; exit; }
|
[ -z "$1" ] && {
|
||||||
|
"$BROWSER"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*)
|
*mkv | *webm | *mp4 | *youtube.com/watch* | *youtube.com/playlist* | *youtu.be* | *hooktube.com* | *bitchute.com* | *videos.lukesmith.xyz*)
|
||||||
setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;;
|
setsid -f mpv -quiet "$1" > /dev/null 2>&1
|
||||||
*png|*jpg|*jpe|*jpeg|*gif)
|
;;
|
||||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
|
*png | *jpg | *jpe | *jpeg | *gif)
|
||||||
*pdf|*cbz|*cbr)
|
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 &
|
||||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
|
;;
|
||||||
*mp3|*flac|*opus|*mp3?source*)
|
*pdf | *cbz | *cbr)
|
||||||
qndl "$1" 'curl -LO' >/dev/null 2>&1 ;;
|
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 &
|
||||||
*)
|
;;
|
||||||
[ -f "$1" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$1" >/dev/null 2>&1 || setsid -f "$BROWSER" "$1" >/dev/null 2>&1
|
*mp3 | *flac | *opus | *mp3?source*)
|
||||||
|
qndl "$1" 'curl -LO' > /dev/null 2>&1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
[ -f "$1" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$1" > /dev/null 2>&1 || setsid -f "$BROWSER" "$1" > /dev/null 2>&1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -4,11 +4,11 @@
|
|||||||
# choose the kind of screenshot to take, including copying the image or even
|
# choose the kind of screenshot to take, including copying the image or even
|
||||||
# highlighting an area to copy. scrotcucks on suicidewatch right now.
|
# highlighting an area to copy. scrotcucks on suicidewatch right now.
|
||||||
|
|
||||||
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
|
case "$(printf 'a selected area\ncurrent window\nfull screen\na selected area (copy)\ncurrent window (copy)\nfull screen (copy)' | dmenu -l 6 -i -p "Screenshot which area?")" in
|
||||||
"a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
"a selected area") maim -s pic-selected-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||||
"current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
"current window") maim -i "$(xdotool getactivewindow)" pic-window-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||||
"full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
"full screen") maim pic-full-"$(date '+%y%m%d-%H%M-%S').png" ;;
|
||||||
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
|
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
|
||||||
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
|
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
|
||||||
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
|
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
basename="$(echo "${*}" | sed 's/\.[^\/.]*$//')"
|
basename="$(echo "${*}" | sed 's/\.[^\/.]*$//')"
|
||||||
|
|
||||||
case "${*}" in
|
case "${*}" in
|
||||||
*.tex|*.m[dse]|*.[rR]md|*.mom|*.[0-9]) setsid -f xdg-open "$basename".pdf >/dev/null 2>&1 ;;
|
*.tex | *.m[dse] | *.[rR]md | *.mom | *.[0-9]) setsid -f xdg-open "$basename".pdf > /dev/null 2>&1 ;;
|
||||||
*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;;
|
*.html) setsid -f "$BROWSER" "$basename".html > /dev/null 2>&1 ;;
|
||||||
*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;;
|
*.sent) setsid -f sent "$1" > /dev/null 2>&1 ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -6,5 +6,5 @@
|
|||||||
# (with other things) by default and is used in some other places.
|
# (with other things) by default and is used in some other places.
|
||||||
|
|
||||||
for i in $(ls /tmp/mpvSockets/*); do
|
for i in $(ls /tmp/mpvSockets/*); do
|
||||||
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i";
|
echo '{ "command": ["set_property", "pause", true] }' | socat - "$i"
|
||||||
done
|
done
|
||||||
|
|||||||
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
[ "$(pgrep -x "$(basename "$0")" | wc -l)" -gt 2 ] && exit
|
[ "$(pgrep -x "$(basename "$0")" | wc -l)" -gt 2 ] && exit
|
||||||
|
|
||||||
echo "${XDG_DATA_HOME:-$HOME/.local/share}"/newsboat/queue | entr -p queueandnotify 2>/dev/null
|
echo "${XDG_DATA_HOME:-$HOME/.local/share}"/newsboat/queue | entr -p queueandnotify 2> /dev/null
|
||||||
|
|||||||
@ -5,4 +5,4 @@
|
|||||||
# For example:
|
# For example:
|
||||||
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
|
# `./prompt "Do you want to shutdown?" "shutdown -h now"`
|
||||||
|
|
||||||
[ "$(printf "No\\nYes" | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray )" = "Yes" ] && $2
|
[ "$(printf 'No\nYes' | dmenu -i -p "$1" -nb darkred -sb red -sf white -nf gray)" = "Yes" ] && $2
|
||||||
|
|||||||
@ -6,9 +6,9 @@
|
|||||||
queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue"
|
queuefile="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/queue"
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
[ -z "$line" ] && continue
|
[ -z "$line" ] && continue
|
||||||
url="$(echo "$line" | awk '{print $1}')"
|
url="$(echo "$line" | awk '{print $1}')"
|
||||||
qndl "$url" "curl -LO"
|
qndl "$url" "curl -LO"
|
||||||
done < "$queuefile"
|
done < "$queuefile"
|
||||||
|
|
||||||
echo > "$queuefile"
|
echo > "$queuefile"
|
||||||
|
|||||||
@ -6,7 +6,8 @@ xset r rate 300 50
|
|||||||
# Map the caps lock key to super...
|
# Map the caps lock key to super...
|
||||||
setxkbmap -option caps:super
|
setxkbmap -option caps:super
|
||||||
# But when it is pressed only once, treat it as escape.
|
# But when it is pressed only once, treat it as escape.
|
||||||
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
|
killall xcape 2> /dev/null
|
||||||
|
xcape -e 'Super_L=Escape'
|
||||||
# Map the menu button to right super as well.
|
# Map the menu button to right super as well.
|
||||||
xmodmap -e 'keycode 135 = Super_R'
|
xmodmap -e 'keycode 135 = Super_R'
|
||||||
# Turn off the caps lock if on since there is no longer a key for it.
|
# Turn off the caps lock if on since there is no longer a key for it.
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null &&
|
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" > /dev/null \
|
||||||
notify-send "That doesn't look like a full URL." && exit
|
&& notify-send "That doesn't look like a full URL." && exit
|
||||||
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
|
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
|
||||||
if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then
|
if awk '{print $1}' "$RSSFILE" | grep "^$1$" > /dev/null; then
|
||||||
notify-send "You already have this RSS feed."
|
notify-send "You already have this RSS feed."
|
||||||
else
|
else
|
||||||
echo "$1" >> "$RSSFILE" && notify-send "RSS feed added."
|
echo "$1" >> "$RSSFILE" && notify-send "RSS feed added."
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -9,16 +9,19 @@
|
|||||||
# Location of link to wallpaper link.
|
# Location of link to wallpaper link.
|
||||||
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
|
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
|
||||||
|
|
||||||
trueloc="$(readlink -f "$1")" &&
|
trueloc="$(readlink -f "$1")" \
|
||||||
case "$(file --mime-type -b "$trueloc")" in
|
&& case "$(file --mime-type -b "$trueloc")" in
|
||||||
image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
|
image/*) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
|
||||||
inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
|
inode/directory) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
|
||||||
*) notify-send "Error" "Not a valid image." ; exit 1;;
|
*)
|
||||||
esac
|
notify-send "Error" "Not a valid image."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# If pywal is installed, use it.
|
# If pywal is installed, use it.
|
||||||
command -v wal >/dev/null 2>&1 &&
|
command -v wal > /dev/null 2>&1 \
|
||||||
wal -i "$trueloc" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 &&
|
&& wal -i "$trueloc" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" > /dev/null 2>&1 \
|
||||||
pidof dwm >/dev/null && xdotool key super+F12
|
&& pidof dwm > /dev/null && xdotool key super+F12
|
||||||
|
|
||||||
xwallpaper --zoom "$bgloc"
|
xwallpaper --zoom "$bgloc"
|
||||||
|
|||||||
@ -12,14 +12,14 @@ fish_shortcuts="/dev/null"
|
|||||||
vifm_shortcuts="/dev/null"
|
vifm_shortcuts="/dev/null"
|
||||||
|
|
||||||
# Remove, prepare files
|
# Remove, prepare files
|
||||||
rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 2>/dev/null
|
rm -f "$ranger_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" 2> /dev/null
|
||||||
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
printf '# vim: filetype=sh\n' > "$fish_shortcuts"
|
||||||
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
printf '# vim: filetype=sh\nalias ' > "$shell_shortcuts"
|
||||||
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
printf '" vim: filetype=vim\n' > "$vifm_shortcuts"
|
||||||
|
|
||||||
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
# Format the `directories` file in the correct syntax and sent it to all three configs.
|
||||||
eval "echo \"$(cat "$bmdirs")\"" | \
|
eval "echo \"$(cat "$bmdirs")\"" \
|
||||||
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
| awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||||
printf(\"%s=\42cd %s && ls -a\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
printf(\"%s=\42cd %s && ls -a\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||||
printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
printf(\"abbr %s \42cd %s; and ls -a\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||||
@ -28,8 +28,8 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
|||||||
printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }"
|
printf(\"map g%s cd %s\nmap t%s tab_new %s\nmap m%s shell mv -v %%s %s\nmap Y%s shell cp -rv %%s %s \n\",\$1,\$2,\$1,\$2, \$1, \$2, \$1, \$2) >> \"$ranger_shortcuts\" }"
|
||||||
|
|
||||||
# Format the `files` file in the correct syntax and sent it to both configs.
|
# Format the `files` file in the correct syntax and sent it to both configs.
|
||||||
eval "echo \"$(cat "$bmfiles")\"" | \
|
eval "echo \"$(cat "$bmfiles")\"" \
|
||||||
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
| awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
|
||||||
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
|
||||||
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
|
||||||
printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ;
|
||||||
|
|||||||
@ -10,25 +10,29 @@
|
|||||||
cache="${XDG_CACHE_HOME:-$HOME/.cache}/slider"
|
cache="${XDG_CACHE_HOME:-$HOME/.cache}/slider"
|
||||||
|
|
||||||
while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
|
while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
|
||||||
c) bgc="$OPTARG" ;;
|
c) bgc="$OPTARG" ;;
|
||||||
t) fgc="$OPTARG" ;;
|
t) fgc="$OPTARG" ;;
|
||||||
i) file="$OPTARG" ;;
|
i) file="$OPTARG" ;;
|
||||||
a) audio="$OPTARG" ;;
|
a) audio="$OPTARG" ;;
|
||||||
o) outfile="$OPTARG" ;;
|
o) outfile="$OPTARG" ;;
|
||||||
d) prepdir="$OPTARG" ;;
|
d) prepdir="$OPTARG" ;;
|
||||||
r) redo="$OPTARG" ;;
|
r) redo="$OPTARG" ;;
|
||||||
s) ppt="$OPTARG" ;;
|
s) ppt="$OPTARG" ;;
|
||||||
e) endtime="$OPTARG" ;;
|
e) endtime="$OPTARG" ;;
|
||||||
x) res="$OPTARG"
|
x)
|
||||||
echo "$res" | grep -qv "^[0-9]\+x[0-9]\+$" &&
|
res="$OPTARG"
|
||||||
echo "Resolution must be dimensions separated by a 'x': 1280x720, etc." &&
|
echo "$res" | grep -qv "^[0-9]\+x[0-9]\+$" \
|
||||||
exit 1 ;;
|
&& echo "Resolution must be dimensions separated by a 'x': 1280x720, etc." \
|
||||||
p) echo "Purge old build files in $cache? [y/N]"
|
&& exit 1
|
||||||
read -r confirm
|
;;
|
||||||
echo "$confirm" | grep -iq "^y$" && rm -rf "$cache" && echo "Done."
|
p)
|
||||||
exit ;;
|
echo "Purge old build files in $cache? [y/N]"
|
||||||
v) verbose=True ;;
|
read -r confirm
|
||||||
*) echo "$(basename "$0") usage:
|
echo "$confirm" | grep -iq "^y$" && rm -rf "$cache" && echo "Done."
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
v) verbose=True ;;
|
||||||
|
*) echo "$(basename "$0") usage:
|
||||||
-i input timecode list (required)
|
-i input timecode list (required)
|
||||||
-a audio file
|
-a audio file
|
||||||
-c color of background (use html names, black is default)
|
-c color of background (use html names, black is default)
|
||||||
@ -40,32 +44,35 @@ while getopts "hvrpi:c:a:o:d:f:t:e:x:" o; do case "${o}" in
|
|||||||
-d tmp directory
|
-d tmp directory
|
||||||
-r rerun imagemagick commands even if done previously (in case files or background has changed)
|
-r rerun imagemagick commands even if done previously (in case files or background has changed)
|
||||||
-p purge old build files instead of running
|
-p purge old build files instead of running
|
||||||
-v be verbose" && exit 1
|
-v be verbose" && exit 1 ;;
|
||||||
|
|
||||||
esac done
|
esac; done
|
||||||
|
|
||||||
# Check that the input file looks like it should.
|
# Check that the input file looks like it should.
|
||||||
{ head -n 1 "$file" 2>/dev/null | grep -q "^00:00:00 " ;} || {
|
{ head -n 1 "$file" 2> /dev/null | grep -q "^00:00:00 "; } || {
|
||||||
echo "Give an input file with -i." &&
|
echo "Give an input file with -i." \
|
||||||
echo "The file should look as this example:
|
&& echo "The file should look as this example:
|
||||||
|
|
||||||
00:00:00 first_image.jpg
|
00:00:00 first_image.jpg
|
||||||
00:00:03 otherdirectory/next_image.jpg
|
00:00:03 otherdirectory/next_image.jpg
|
||||||
00:00:09 this_image_starts_at_9_seconds.jpg
|
00:00:09 this_image_starts_at_9_seconds.jpg
|
||||||
etc...
|
etc...
|
||||||
|
|
||||||
Timecodes and filenames must be separated by Tabs." &&
|
Timecodes and filenames must be separated by Tabs." \
|
||||||
exit 1
|
&& exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -n "${audio+x}" ]; then
|
if [ -n "${audio+x}" ]; then
|
||||||
# Check that the audio file looks like an actual audio file.
|
# Check that the audio file looks like an actual audio file.
|
||||||
case "$(file --dereference --brief --mime-type -- "$audio")" in
|
case "$(file --dereference --brief --mime-type -- "$audio")" in
|
||||||
audio/*) ;;
|
audio/*) ;;
|
||||||
*) echo "That doesn't look like an audio file."; exit 1 ;;
|
*)
|
||||||
esac
|
echo "That doesn't look like an audio file."
|
||||||
totseconds="$(date '+%s' -d $(ffmpeg -i "$audio" 2>&1 | awk '/Duration/ {print $2}' | sed s/,//))"
|
exit 1
|
||||||
endtime="$((totseconds-seconds))"
|
;;
|
||||||
|
esac
|
||||||
|
totseconds="$(date '+%s' -d $(ffmpeg -i "$audio" 2>&1 | awk '/Duration/ {print $2}' | sed s/,//))"
|
||||||
|
endtime="$((totseconds - seconds))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prepdir="${prepdir:-$cache/$file}"
|
prepdir="${prepdir:-$cache/$file}"
|
||||||
@ -76,47 +83,46 @@ prepfile="$prepdir/$file.prep"
|
|||||||
mkdir -p "$prepdir"
|
mkdir -p "$prepdir"
|
||||||
|
|
||||||
{
|
{
|
||||||
while read -r x;
|
while read -r x; do
|
||||||
do
|
# Get the time from the first column.
|
||||||
# Get the time from the first column.
|
time="${x%% *}"
|
||||||
time="${x%% *}"
|
seconds="$(date '+%s' -d "$time")"
|
||||||
seconds="$(date '+%s' -d "$time")"
|
# Duration is not used on the first looped item.
|
||||||
# Duration is not used on the first looped item.
|
duration="$((seconds - prevseconds))"
|
||||||
duration="$((seconds - prevseconds))"
|
|
||||||
|
|
||||||
# Get the filename/text content from the rest.
|
# Get the filename/text content from the rest.
|
||||||
content="${x#* }"
|
content="${x#* }"
|
||||||
base="$(basename "$content")"
|
base="$(basename "$content")"
|
||||||
base="${base%.*}.jpg"
|
base="${base%.*}.jpg"
|
||||||
|
|
||||||
if [ -f "$content" ]; then
|
if [ -f "$content" ]; then
|
||||||
# If images have already been made in a previous run, do not recreate
|
# If images have already been made in a previous run, do not recreate
|
||||||
# them unless -r was given.
|
# them unless -r was given.
|
||||||
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} &&
|
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ]; } \
|
||||||
convert -size "${res:-1920x1080}" canvas:"${bgc:-black}" -gravity center "$content" -resize 1920x1080 -composite "$prepdir/$base"
|
&& convert -size "${res:-1920x1080}" canvas:"${bgc:-black}" -gravity center "$content" -resize 1920x1080 -composite "$prepdir/$base"
|
||||||
else
|
else
|
||||||
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} &&
|
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ]; } \
|
||||||
convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
|
&& convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the first line, do not write yet.
|
# If the first line, do not write yet.
|
||||||
[ "$time" = "00:00:00" ] || echo "file '$prevbase'
|
[ "$time" = "00:00:00" ] || echo "file '$prevbase'
|
||||||
duration $duration"
|
duration $duration"
|
||||||
|
|
||||||
# Keep the information required for the next file.
|
# Keep the information required for the next file.
|
||||||
prevbase="$base"
|
prevbase="$base"
|
||||||
prevtime="$time"
|
prevtime="$time"
|
||||||
prevseconds="$(date '+%s' -d "$prevtime")"
|
prevseconds="$(date '+%s' -d "$prevtime")"
|
||||||
done < "$file"
|
done < "$file"
|
||||||
# Do last file which must be given twice as follows
|
# Do last file which must be given twice as follows
|
||||||
echo "file '$base'
|
echo "file '$base'
|
||||||
duration ${endtime:-5}
|
duration ${endtime:-5}
|
||||||
file '$base'"
|
file '$base'"
|
||||||
} > "$prepfile"
|
} > "$prepfile"
|
||||||
if [ -n "${audio+x}" ]; then
|
if [ -n "${audio+x}" ]; then
|
||||||
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -i "$audio" -c:a aac -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
|
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -i "$audio" -c:a aac -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
|
||||||
else
|
else
|
||||||
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
|
ffmpeg -hide_banner -y -f concat -safe 0 -i "$prepfile" -vsync vfr -c:v libx264 -pix_fmt yuv420p "$outfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Might also try:
|
# Might also try:
|
||||||
|
|||||||
@ -4,33 +4,34 @@
|
|||||||
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
|
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
3) notify-send "🔋 Battery module" "🔋: discharging
|
3) notify-send "🔋 Battery module" "🔋: discharging
|
||||||
🛑: not charging
|
🛑: not charging
|
||||||
♻: stagnant charge
|
♻: stagnant charge
|
||||||
🔌: charging
|
🔌: charging
|
||||||
⚡: charged
|
⚡: charged
|
||||||
❗: battery very low!
|
❗: battery very low!
|
||||||
- Scroll to change adjust xbacklight." ;;
|
- Scroll to change adjust xbacklight." ;;
|
||||||
4) xbacklight -inc 10 ;;
|
4) xbacklight -inc 10 ;;
|
||||||
5) xbacklight -dec 10 ;;
|
5) xbacklight -dec 10 ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Loop through all attached batteries and format the info
|
# Loop through all attached batteries and format the info
|
||||||
for battery in /sys/class/power_supply/BAT?*; do
|
for battery in /sys/class/power_supply/BAT?*; do
|
||||||
# If non-first battery, print a space separator.
|
# If non-first battery, print a space separator.
|
||||||
[ -n "${capacity+x}" ] && printf " "
|
[ -n "${capacity+x}" ] && printf " "
|
||||||
# Sets up the status and capacity
|
# Sets up the status and capacity
|
||||||
case "$(cat "$battery/status")" in
|
case "$(cat "$battery/status")" in
|
||||||
"Full") status="⚡" ;;
|
"Full") status="⚡" ;;
|
||||||
"Discharging") status="🔋" ;;
|
"Discharging") status="🔋" ;;
|
||||||
"Charging") status="🔌" ;;
|
"Charging") status="🔌" ;;
|
||||||
"Not charging") status="🛑" ;;
|
"Not charging") status="🛑" ;;
|
||||||
"Unknown") status="♻️" ;;
|
"Unknown") status="♻️" ;;
|
||||||
esac
|
esac
|
||||||
capacity=$(cat "$battery/capacity")
|
capacity=$(cat "$battery/capacity")
|
||||||
# Will make a warn variable if discharging and low
|
# Will make a warn variable if discharging and low
|
||||||
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
|
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
|
||||||
# Prints the info
|
# Prints the info
|
||||||
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
|
printf "%s%s%d%%" "$status" "$warn" "$capacity"
|
||||||
|
unset warn
|
||||||
done && exit 0
|
done && exit 0
|
||||||
|
|||||||
@ -3,27 +3,27 @@
|
|||||||
clock=$(date '+%I')
|
clock=$(date '+%I')
|
||||||
|
|
||||||
case "$clock" in
|
case "$clock" in
|
||||||
"00") icon="🕛" ;;
|
"00") icon="🕛" ;;
|
||||||
"01") icon="🕐" ;;
|
"01") icon="🕐" ;;
|
||||||
"02") icon="🕑" ;;
|
"02") icon="🕑" ;;
|
||||||
"03") icon="🕒" ;;
|
"03") icon="🕒" ;;
|
||||||
"04") icon="🕓" ;;
|
"04") icon="🕓" ;;
|
||||||
"05") icon="🕔" ;;
|
"05") icon="🕔" ;;
|
||||||
"06") icon="🕕" ;;
|
"06") icon="🕕" ;;
|
||||||
"07") icon="🕖" ;;
|
"07") icon="🕖" ;;
|
||||||
"08") icon="🕗" ;;
|
"08") icon="🕗" ;;
|
||||||
"09") icon="🕘" ;;
|
"09") icon="🕘" ;;
|
||||||
"10") icon="🕙" ;;
|
"10") icon="🕙" ;;
|
||||||
"11") icon="🕚" ;;
|
"11") icon="🕚" ;;
|
||||||
"12") icon="🕛" ;;
|
"12") icon="🕛" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
|
1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
|
||||||
2) setsid -f "$TERMINAL" -e calcurse ;;
|
2) setsid -f "$TERMINAL" -e calcurse ;;
|
||||||
3) notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
|
3) notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
|
||||||
- Middle click opens calcurse if installed" ;;
|
- Middle click opens calcurse if installed" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
date "+%Y %b %d (%a) $icon%I:%M%p"
|
date "+%Y %b %d (%a) $icon%I:%M%p"
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;;
|
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;;
|
||||||
2) setsid -f "$TERMINAL" -e htop ;;
|
2) setsid -f "$TERMINAL" -e htop ;;
|
||||||
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
|
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
|
||||||
- Click to show intensive processes.
|
- Click to show intensive processes.
|
||||||
- Middle click to open htop." ;;
|
- Middle click to open htop." ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
sensors | awk '/Core 0/ {print "🌡" $3}'
|
sensors | awk '/Core 0/ {print "🌡" $3}'
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
cache=/tmp/cpubarscache
|
cache=/tmp/cpubarscache
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
2) setsid -f "$TERMINAL" -e htop ;;
|
2) setsid -f "$TERMINAL" -e htop ;;
|
||||||
3) notify-send "🪨 CPU load module" "Each bar represents
|
3) notify-send "🪨 CPU load module" "Each bar represents
|
||||||
one CPU core";;
|
one CPU core" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# id total idle
|
# id total idle
|
||||||
@ -21,24 +21,25 @@ stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5)
|
|||||||
old=$(cat "$cache")
|
old=$(cat "$cache")
|
||||||
printf "🪨"
|
printf "🪨"
|
||||||
echo "$stats" | while read -r row; do
|
echo "$stats" | while read -r row; do
|
||||||
id=${row%% *}
|
id=${row%% *}
|
||||||
rest=${row#* }
|
rest=${row#* }
|
||||||
total=${rest%% *}
|
total=${rest%% *}
|
||||||
idle=${rest##* }
|
idle=${rest##* }
|
||||||
|
|
||||||
case "$(echo "$old" | awk '{if ($1 == id)
|
case "$(echo "$old" | awk '{if ($1 == id)
|
||||||
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
|
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
|
||||||
id="$id" total="$total" idle="$idle")" in
|
id="$id" total="$total" idle="$idle")" in
|
||||||
|
|
||||||
"0") printf "▁";;
|
"0") printf "▁" ;;
|
||||||
"1") printf "▂";;
|
"1") printf "▂" ;;
|
||||||
"2") printf "▃";;
|
"2") printf "▃" ;;
|
||||||
"3") printf "▄";;
|
"3") printf "▄" ;;
|
||||||
"4") printf "▅";;
|
"4") printf "▅" ;;
|
||||||
"5") printf "▆";;
|
"5") printf "▆" ;;
|
||||||
"6") printf "▇";;
|
"6") printf "▇" ;;
|
||||||
"7") printf "█";;
|
"7") printf "█" ;;
|
||||||
"8") printf "█";;
|
"8") printf "█" ;;
|
||||||
esac
|
esac
|
||||||
done; printf "\\n"
|
done
|
||||||
|
printf '\n'
|
||||||
echo "$stats" > "$cache"
|
echo "$stats" > "$cache"
|
||||||
|
|||||||
@ -8,16 +8,16 @@ location=${1:-/}
|
|||||||
[ -d "$location" ] || exit
|
[ -d "$location" ] || exit
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
|
1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
|
||||||
3) notify-send "💽 Disk module" "\- Shows used hard drive space.
|
3) notify-send "💽 Disk module" "\- Shows used hard drive space.
|
||||||
- Click to show all disk info." ;;
|
- Click to show all disk info." ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$location" in
|
case "$location" in
|
||||||
"/home"* ) icon="🏠" ;;
|
"/home"*) icon="🏠" ;;
|
||||||
"/mnt"* ) icon="💾" ;;
|
"/mnt"*) icon="💾" ;;
|
||||||
*) icon="🖥";;
|
*) icon="🖥" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
||||||
|
|||||||
@ -7,29 +7,31 @@
|
|||||||
# You could set up a shell alias to view the full file in a pager in the
|
# You could set up a shell alias to view the full file in a pager in the
|
||||||
# terminal if desired. This function will only be run once a day when needed.
|
# terminal if desired. This function will only be run once a day when needed.
|
||||||
weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
|
weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport"
|
||||||
getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;}
|
getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1; }
|
||||||
|
|
||||||
# Some very particular and terse stream manipulation. We get the maximum
|
# Some very particular and terse stream manipulation. We get the maximum
|
||||||
# precipitation chance and the daily high and low from the downloaded file and
|
# precipitation chance and the daily high and low from the downloaded file and
|
||||||
# display them with coresponding emojis.
|
# display them with coresponding emojis.
|
||||||
showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" |
|
showweather() {
|
||||||
grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')"
|
printf "%s" "$(sed '16q;d' "$weatherreport" \
|
||||||
sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}' ;}
|
| grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')"
|
||||||
|
sed '13q;d' "$weatherreport" | grep -o 'm\([-+]\)*[0-9]\+' | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}'
|
||||||
|
}
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
|
1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
|
||||||
2) getforecast && showweather ;;
|
2) getforecast && showweather ;;
|
||||||
3) notify-send "🌈 Weather module" "\- Left click for full forecast.
|
3) notify-send "🌈 Weather module" "\- Left click for full forecast.
|
||||||
- Middle click to update forecast.
|
- Middle click to update forecast.
|
||||||
☔: Chance of rain/snow
|
☔: Chance of rain/snow
|
||||||
🥶: Daily low
|
🥶: Daily low
|
||||||
🌞: Daily high" ;;
|
🌞: Daily high" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# The test if our forcecast is updated to the day. If it isn't download a new
|
# The test if our forcecast is updated to the day. If it isn't download a new
|
||||||
# weather report from wttr.in with the above function.
|
# weather report from wttr.in with the above function.
|
||||||
[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
[ "$(stat -c %y "$weatherreport" 2> /dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] \
|
||||||
getforecast
|
|| getforecast
|
||||||
|
|
||||||
showweather
|
showweather
|
||||||
|
|||||||
@ -3,15 +3,16 @@
|
|||||||
# The clickable help menu. Middle click to restart wm.
|
# The clickable help menu. Middle click to restart wm.
|
||||||
|
|
||||||
# If dwm is running, use dwm's readme and restart.
|
# If dwm is running, use dwm's readme and restart.
|
||||||
pidof dwm >/dev/null &&
|
pidof dwm > /dev/null \
|
||||||
READMEFILE=/usr/local/share/dwm/larbs.mom
|
&& READMEFILE=/usr/local/share/dwm/larbs.mom
|
||||||
restartwm() { pkill -HUP dwm ;} ||
|
restartwm() { pkill -HUP dwm; } \
|
||||||
restartwm() { i3 restart ;}
|
|| restartwm() { i3 restart; }
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;;
|
1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;;
|
||||||
2) restartwm ;;
|
2) restartwm ;;
|
||||||
3) notify-send "❓ Help module" "\- Left click to open LARBS guide.
|
3) notify-send "❓ Help module" "\- Left click to open LARBS guide.
|
||||||
- Middle click to refresh window manager." ;;
|
- Middle click to refresh window manager." ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac; echo "❓"
|
esac
|
||||||
|
echo "❓"
|
||||||
|
|||||||
@ -5,20 +5,23 @@
|
|||||||
# Show 🔒 if a vpn connection is active
|
# Show 🔒 if a vpn connection is active
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
|
1)
|
||||||
3) notify-send "🌐 Internet module" "\- Click to connect
|
"$TERMINAL" -e nmtui
|
||||||
|
pkill -RTMIN+4 dwmblocks
|
||||||
|
;;
|
||||||
|
3) notify-send "🌐 Internet module" "\- Click to connect
|
||||||
📡: no wifi connection
|
📡: no wifi connection
|
||||||
📶: wifi connection with quality
|
📶: wifi connection with quality
|
||||||
❎: no ethernet
|
❎: no ethernet
|
||||||
🌐: ethernet working
|
🌐: ethernet working
|
||||||
🔒: vpn is active
|
🔒: vpn is active
|
||||||
" ;;
|
" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
|
case "$(cat /sys/class/net/w*/operstate 2> /dev/null)" in
|
||||||
down) wifiicon="📡 " ;;
|
down) wifiicon="📡 " ;;
|
||||||
up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
|
up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)"
|
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2> /dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2> /dev/null)"
|
||||||
|
|||||||
@ -6,5 +6,5 @@
|
|||||||
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
||||||
|
|
||||||
ifinstalled "geoip" || exit
|
ifinstalled "geoip" || exit
|
||||||
addr="$(curl ifconfig.me 2>/dev/null)" || exit
|
addr="$(curl ifconfig.me 2> /dev/null)" || exit
|
||||||
grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"
|
grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"
|
||||||
|
|||||||
@ -4,13 +4,15 @@
|
|||||||
kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
|
kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
|
1)
|
||||||
kb="$(echo "$kb_choice" | awk '{print $3}')"
|
kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
|
||||||
setxkbmap "$kb"
|
kb="$(echo "$kb_choice" | awk '{print $3}')"
|
||||||
pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";;
|
setxkbmap "$kb"
|
||||||
3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')")
|
pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}"
|
||||||
- Left click to change keyboard.";;
|
;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')")
|
||||||
|
- Left click to change keyboard." ;;
|
||||||
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "$kb"
|
echo "$kb"
|
||||||
|
|||||||
@ -4,17 +4,17 @@
|
|||||||
# When clicked, brings up `neomutt`.
|
# When clicked, brings up `neomutt`.
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e neomutt ;;
|
1) setsid -f "$TERMINAL" -e neomutt ;;
|
||||||
2) setsid -f mw sync >/dev/null ;;
|
2) setsid -f mw sync > /dev/null ;;
|
||||||
3) notify-send "📬 Mail module" "\- Shows unread mail
|
3) notify-send "📬 Mail module" "\- Shows unread mail
|
||||||
- Shows 🔃 if syncing mail
|
- Shows 🔃 if syncing mail
|
||||||
- Left click opens neomutt
|
- Left click opens neomutt
|
||||||
- Middle click syncs mail" ;;
|
- Middle click syncs mail" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
|
unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2> /dev/null)"
|
||||||
|
|
||||||
pidof mbsync >/dev/null 2>&1 && icon="🔃"
|
pidof mbsync > /dev/null 2>&1 && icon="🔃"
|
||||||
|
|
||||||
[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "📬$unread$icon"
|
[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "📬$unread$icon"
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
|
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
|
||||||
2) setsid -f "$TERMINAL" -e htop ;;
|
2) setsid -f "$TERMINAL" -e htop ;;
|
||||||
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
|
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
|
||||||
- Click to show memory hogs.
|
- Click to show memory hogs.
|
||||||
- Middle click to open htop." ;;
|
- Middle click to open htop." ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
|
free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
|
||||||
|
|||||||
@ -4,27 +4,27 @@
|
|||||||
|
|
||||||
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
|
||||||
|
|
||||||
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
|
[ "$(stat -c %y "$moonfile" 2> /dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] \
|
||||||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
|
|| { curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1; }
|
||||||
|
|
||||||
icon="$(cat "$moonfile")"
|
icon="$(cat "$moonfile")"
|
||||||
|
|
||||||
case "$icon" in
|
case "$icon" in
|
||||||
🌑) name="New" ;;
|
🌑) name="New" ;;
|
||||||
🌒) name="Waxing Crescent" ;;
|
🌒) name="Waxing Crescent" ;;
|
||||||
🌓) name="First Quarter" ;;
|
🌓) name="First Quarter" ;;
|
||||||
🌔) name="Waxing Gibbous" ;;
|
🌔) name="Waxing Gibbous" ;;
|
||||||
🌕) name="Full" ;;
|
🌕) name="Full" ;;
|
||||||
🌖) name="Waning Gibbous" ;;
|
🌖) name="Waning Gibbous" ;;
|
||||||
🌗) name="Last Quarter" ;;
|
🌗) name="Last Quarter" ;;
|
||||||
🌘) name="Waning Crescent" ;;
|
🌘) name="Waning Crescent" ;;
|
||||||
*) exit 1 ;;
|
*) exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "${icon-?}"
|
echo "${icon-?}"
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
3) notify-send "🌜 Moon phase module" "Displays current moon phase.
|
3) notify-send "🌜 Moon phase module" "Displays current moon phase.
|
||||||
- 🌑: New
|
- 🌑: New
|
||||||
- 🌒: Waxing Crescent
|
- 🌒: Waxing Crescent
|
||||||
- 🌓: First Quarter
|
- 🌓: First Quarter
|
||||||
@ -33,5 +33,5 @@ case $BLOCK_BUTTON in
|
|||||||
- 🌖: Waning Gibbous
|
- 🌖: Waning Gibbous
|
||||||
- 🌗: Last Quarter
|
- 🌗: Last Quarter
|
||||||
- 🌘: Waning Crescent" ;;
|
- 🌘: Waning Crescent" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -3,6 +3,6 @@
|
|||||||
# This loop will update the mpd statusbar module whenever a command changes the
|
# This loop will update the mpd statusbar module whenever a command changes the
|
||||||
# music player's status. mpd must be running on X's start for this to work.
|
# music player's status. mpd must be running on X's start for this to work.
|
||||||
|
|
||||||
while : ; do
|
while :; do
|
||||||
mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break
|
mpc idle > /dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break
|
||||||
done
|
done
|
||||||
|
|||||||
@ -1,19 +1,28 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d" | paste -sd ' ' -;}
|
filter() { mpc | sed '/^volume:/d;s/\&/&/g;s/\[paused\].*/⏸/g;/\[playing\].*/d' | paste -sd ' ' -; }
|
||||||
|
|
||||||
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
|
pidof -x sb-mpdup > /dev/null 2>&1 || sb-mpdup > /dev/null 2>&1 &
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
|
1)
|
||||||
2) mpc toggle | filter ;; # right click, pause/unpause
|
mpc status | filter
|
||||||
3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing.
|
setsid -f "$TERMINAL" -e ncmpcpp
|
||||||
|
;; # right click, pause/unpause
|
||||||
|
2) mpc toggle | filter ;; # right click, pause/unpause
|
||||||
|
3)
|
||||||
|
mpc status | filter
|
||||||
|
notify-send "🎵 Music module" "\- Shows mpd song playing.
|
||||||
- ⏸ when paused.
|
- ⏸ when paused.
|
||||||
- Left click opens ncmpcpp.
|
- Left click opens ncmpcpp.
|
||||||
- Middle click pauses.
|
- Middle click pauses.
|
||||||
- Scroll changes track.";; # right click, pause/unpause
|
- Scroll changes track."
|
||||||
4) mpc prev | filter ;; # scroll up, previous
|
;; # right click, pause/unpause
|
||||||
5) mpc next | filter ;; # scroll down, next
|
4) mpc prev | filter ;; # scroll up, previous
|
||||||
6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
|
5) mpc next | filter ;; # scroll down, next
|
||||||
*) mpc status | filter ;;
|
6)
|
||||||
|
mpc status | filter
|
||||||
|
"$TERMINAL" -e "$EDITOR" "$0"
|
||||||
|
;;
|
||||||
|
*) mpc status | filter ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -5,25 +5,25 @@
|
|||||||
# second, gives network traffic per second.
|
# second, gives network traffic per second.
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e bmon ;;
|
1) setsid -f "$TERMINAL" -e bmon ;;
|
||||||
3) notify-send "🌐 Network traffic module" "🔻: Traffic received
|
3) notify-send "🌐 Network traffic module" "🔻: Traffic received
|
||||||
🔺: Traffic transmitted" ;;
|
🔺: Traffic transmitted" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
sum=0
|
sum=0
|
||||||
for arg; do
|
for arg; do
|
||||||
read -r i < "$arg"
|
read -r i < "$arg"
|
||||||
sum=$(( sum + i ))
|
sum=$((sum + i))
|
||||||
done
|
done
|
||||||
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
|
||||||
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
[ -f "$cache" ] && read -r old < "$cache" || old=0
|
||||||
printf %d\\n "$sum" > "$cache"
|
printf %d\\n "$sum" > "$cache"
|
||||||
printf %d\\n $(( sum - old ))
|
printf %d\\n $((sum - old))
|
||||||
}
|
}
|
||||||
|
|
||||||
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
||||||
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
||||||
|
|
||||||
printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
|
printf '🔻%4sB 🔺%4sB\n' $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
|
||||||
|
|||||||
@ -4,14 +4,14 @@
|
|||||||
# When clicked, brings up `newsboat`.
|
# When clicked, brings up `newsboat`.
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid "$TERMINAL" -e newsboat ;;
|
1) setsid "$TERMINAL" -e newsboat ;;
|
||||||
2) setsid -f newsup >/dev/null exit ;;
|
2) setsid -f newsup exit > /dev/null ;;
|
||||||
3) notify-send "📰 News module" "\- Shows unread news items
|
3) notify-send "📰 News module" "\- Shows unread news items
|
||||||
- Shows 🔃 if updating with \`newsup\`
|
- Shows 🔃 if updating with \`newsup\`
|
||||||
- Left click opens newsboat
|
- Left click opens newsboat
|
||||||
- Middle click syncs RSS feeds
|
- Middle click syncs RSS feeds
|
||||||
<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
|
<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)"
|
cat /tmp/newsupdate 2> /dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2> /dev/null)"
|
||||||
|
|||||||
@ -18,12 +18,12 @@
|
|||||||
# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks # Or i3blocks if using i3.
|
# Exec = /usr/bin/pkill -RTMIN+8 dwmblocks # Or i3blocks if using i3.
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e sb-popupgrade ;;
|
1) setsid -f "$TERMINAL" -e sb-popupgrade ;;
|
||||||
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
|
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
|
||||||
3) notify-send "🎁 Upgrade module" "📦: number of upgradable packages
|
3) notify-send "🎁 Upgrade module" "📦: number of upgradable packages
|
||||||
- Left click to upgrade packages
|
- Left click to upgrade packages
|
||||||
- Middle click to show upgradable packages" ;;
|
- Middle click to show upgradable packages" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/📦/;s/^📦0$//g"
|
pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/📦/;s/^📦0$//g"
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
printf "Beginning upgrade.\\n"
|
printf 'Beginning upgrade.\n'
|
||||||
|
|
||||||
yay -Syu
|
yay -Syu
|
||||||
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
||||||
|
|
||||||
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
|
printf '\nUpgrade complete.\nPress <Enter> to exit window.\n\n'
|
||||||
read -r _
|
read -r _
|
||||||
|
|||||||
@ -6,33 +6,37 @@
|
|||||||
# When the name of the currency is multi-word, put it in quotes.
|
# When the name of the currency is multi-word, put it in quotes.
|
||||||
|
|
||||||
[ -z "$3" ] && exit 1
|
[ -z "$3" ] && exit 1
|
||||||
interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
|
interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
|
||||||
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
|
||||||
pricefile="$dir/$1"
|
pricefile="$dir/$1"
|
||||||
chartfile="$dir/$1-chart"
|
chartfile="$dir/$1-chart"
|
||||||
|
|
||||||
updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
|
updateprice() { ping -q -c 1 example.org > /dev/null 2>&1 \
|
||||||
curl -s "rate.sx/1$1" > "$pricefile" &&
|
&& curl -s "rate.sx/1$1" > "$pricefile" \
|
||||||
curl -s "rate.sx/$1$interval" > "$chartfile" ;}
|
&& curl -s "rate.sx/$1$interval" > "$chartfile"; }
|
||||||
|
|
||||||
[ -d "$dir" ] || mkdir -p "$dir"
|
[ -d "$dir" ] || mkdir -p "$dir"
|
||||||
|
|
||||||
[ "$(stat -c %x "$pricefile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
[ "$(stat -c %x "$pricefile" 2> /dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] \
|
||||||
updateprice "$1"
|
&& updateprice "$1"
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;;
|
1) setsid "$TERMINAL" -e less -Srf "$chartfile" ;;
|
||||||
2) notify-send -u low "$3 Updating..." "Updating $2 price..."
|
2)
|
||||||
updateprice "$1" && notify-send "$3 Update complete." "$2 price is now
|
notify-send -u low "$3 Updating..." "Updating $2 price..."
|
||||||
\$$(cat "$pricefile")" ;;
|
updateprice "$1" && notify-send "$3 Update complete." "$2 price is now
|
||||||
3) uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
|
\$$(cat "$pricefile")"
|
||||||
notify-send "$3 $2 module" "\- <b>Exact price: \$$(cat "$pricefile")</b>
|
;;
|
||||||
|
3)
|
||||||
|
uptime="$(date -d "$(stat -c %x "$pricefile")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
|
||||||
|
notify-send "$3 $2 module" "\- <b>Exact price: \$$(cat "$pricefile")</b>
|
||||||
- Left click for chart of changes.
|
- Left click for chart of changes.
|
||||||
- Middle click to update.
|
- Middle click to update.
|
||||||
- Shows 🔃 if updating prices.
|
- Shows 🔃 if updating prices.
|
||||||
- <b>Last updated:
|
- <b>Last updated:
|
||||||
$uptime</b>" ;;
|
$uptime</b>"
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
;;
|
||||||
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "$3$%0.2f" "$(cat "$pricefile")"
|
printf "$3$%0.2f" "$(cat "$pricefile")"
|
||||||
|
|||||||
@ -10,11 +10,11 @@ num=$(tsp -l | awk -v numr=0 -v numq=0 '{if (/running/)numr++; if (/queued/)numq
|
|||||||
|
|
||||||
# Handle mouse clicks
|
# Handle mouse clicks
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e tsp -l ;;
|
1) setsid -f "$TERMINAL" -e tsp -l ;;
|
||||||
3) notify-send "Tasks module" "🤖: number of running/queued background tasks
|
3) notify-send "Tasks module" "🤖: number of running/queued background tasks
|
||||||
- Left click opens tsp" ;; # Right click
|
- Left click opens tsp" ;; # Right click
|
||||||
2) $EDITOR "$0" ;; # Middle click
|
2) $EDITOR "$0" ;; # Middle click
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ "$num" != "0(0)" ] &&
|
[ "$num" != "0(0)" ] \
|
||||||
echo "🤖$num"
|
&& echo "🤖$num"
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
transmission-remote -l | grep % |
|
transmission-remote -l | grep % \
|
||||||
sed " # The letters are for sorting and will not appear.
|
| sed " # The letters are for sorting and will not appear.
|
||||||
s/.*Stopped.*/A 🛑/;
|
s/.*Stopped.*/A 🛑/;
|
||||||
s/.*Seeding.*/Z 🌱/;
|
s/.*Seeding.*/Z 🌱/;
|
||||||
s/.*100%.*/N ✅/;
|
s/.*100%.*/N ✅/;
|
||||||
s/.*Idle.*/B 🕰️/;
|
s/.*Idle.*/B 🕰️/;
|
||||||
s/.*Uploading.*/L ⬆️/;
|
s/.*Uploading.*/L ⬆️/;
|
||||||
s/.*%.*/M ⬇️/" |
|
s/.*%.*/M ⬇️/" \
|
||||||
sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' -
|
| sort -h | uniq -c | awk '{print $3 $1}' | paste -sd ' ' -
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e tremc ;;
|
1) setsid -f "$TERMINAL" -e tremc ;;
|
||||||
2) td-toggle ;;
|
2) td-toggle ;;
|
||||||
3) notify-send "🌱 Torrent module" "\- Left click to open tremc.
|
3) notify-send "🌱 Torrent module" "\- Left click to open tremc.
|
||||||
- Middle click to toggle transmission.
|
- Middle click to toggle transmission.
|
||||||
- Shift click to edit script.
|
- Shift click to edit script.
|
||||||
Module shows number of torrents:
|
Module shows number of torrents:
|
||||||
@ -23,5 +23,5 @@ Module shows number of torrents:
|
|||||||
🔽: downloading
|
🔽: downloading
|
||||||
✅: done
|
✅: done
|
||||||
🌱: done and seeding" ;;
|
🌱: done and seeding" ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
# Prints the current volume or 🔇 if muted.
|
# Prints the current volume or 🔇 if muted.
|
||||||
|
|
||||||
case $BLOCK_BUTTON in
|
case $BLOCK_BUTTON in
|
||||||
1) setsid -f "$TERMINAL" -e pulsemixer ;;
|
1) setsid -f "$TERMINAL" -e pulsemixer ;;
|
||||||
2) pamixer -t ;;
|
2) pamixer -t ;;
|
||||||
4) pamixer --allow-boost -i 1 ;;
|
4) pamixer --allow-boost -i 1 ;;
|
||||||
5) pamixer --allow-boost -d 1 ;;
|
5) pamixer --allow-boost -d 1 ;;
|
||||||
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
||||||
- Middle click to mute.
|
- Middle click to mute.
|
||||||
- Scroll to change." ;;
|
- Scroll to change." ;;
|
||||||
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ $(pamixer --get-mute) = true ] && echo 🔇 && exit
|
[ $(pamixer --get-mute) = true ] && echo 🔇 && exit
|
||||||
@ -18,11 +18,11 @@ esac
|
|||||||
vol="$(pamixer --get-volume)"
|
vol="$(pamixer --get-volume)"
|
||||||
|
|
||||||
if [ "$vol" -gt "70" ]; then
|
if [ "$vol" -gt "70" ]; then
|
||||||
icon="🔊"
|
icon="🔊"
|
||||||
elif [ "$vol" -lt "30" ]; then
|
elif [ "$vol" -lt "30" ]; then
|
||||||
icon="🔈"
|
icon="🔈"
|
||||||
else
|
else
|
||||||
icon="🔉"
|
icon="🔉"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$icon$vol%"
|
echo "$icon$vol%"
|
||||||
|
|||||||
@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
# For non-systemd init systems.
|
# For non-systemd init systems.
|
||||||
case "$(readlink -f /sbin/init)" in
|
case "$(readlink -f /sbin/init)" in
|
||||||
*runit*) hib="sudo -A zzz" ;;
|
*runit*) hib="sudo -A zzz" ;;
|
||||||
*openrc*) reb="sudo -A openrc-shutdown -r"; shut="sudo -A openrc-shutdown -p" ;;
|
*openrc*)
|
||||||
|
reb="sudo -A openrc-shutdown -r"
|
||||||
|
shut="sudo -A openrc-shutdown -p"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cmds="\
|
cmds="\
|
||||||
@ -18,4 +21,4 @@ cmds="\
|
|||||||
|
|
||||||
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
|
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
|
||||||
|
|
||||||
`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-`
|
$(echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-)
|
||||||
|
|||||||
@ -11,20 +11,20 @@ Options:
|
|||||||
-d: year of publication
|
-d: year of publication
|
||||||
-g: genre
|
-g: genre
|
||||||
-c: comment
|
-c: comment
|
||||||
You will be prompted for title, artist, album and track if not given." && exit 1 ;}
|
You will be prompted for title, artist, album and track if not given." && exit 1; }
|
||||||
|
|
||||||
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
|
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
|
||||||
a) artist="${OPTARG}" ;;
|
a) artist="${OPTARG}" ;;
|
||||||
t) title="${OPTARG}" ;;
|
t) title="${OPTARG}" ;;
|
||||||
A) album="${OPTARG}" ;;
|
A) album="${OPTARG}" ;;
|
||||||
n) track="${OPTARG}" ;;
|
n) track="${OPTARG}" ;;
|
||||||
N) total="${OPTARG}" ;;
|
N) total="${OPTARG}" ;;
|
||||||
d) date="${OPTARG}" ;;
|
d) date="${OPTARG}" ;;
|
||||||
g) genre="${OPTARG}" ;;
|
g) genre="${OPTARG}" ;;
|
||||||
c) comment="${OPTARG}" ;;
|
c) comment="${OPTARG}" ;;
|
||||||
f) file="${OPTARG}" ;;
|
f) file="${OPTARG}" ;;
|
||||||
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
|
*) printf 'Invalid option: -%s\n' "$OPTARG" && err ;;
|
||||||
esac done
|
esac; done
|
||||||
|
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ file="$1"
|
|||||||
[ -z "$track" ] && echo "Enter a track number." && read -r track
|
[ -z "$track" ] && echo "Enter a track number." && read -r track
|
||||||
|
|
||||||
case "$file" in
|
case "$file" in
|
||||||
*.ogg) echo "Title=$title
|
*.ogg) echo "Title=$title
|
||||||
Artist=$artist
|
Artist=$artist
|
||||||
Album=$album
|
Album=$album
|
||||||
Track=$track
|
Track=$track
|
||||||
@ -46,7 +46,7 @@ Total=$total
|
|||||||
Date=$date
|
Date=$date
|
||||||
Genre=$genre
|
Genre=$genre
|
||||||
Comment=$comment" | vorbiscomment -w "$file" ;;
|
Comment=$comment" | vorbiscomment -w "$file" ;;
|
||||||
*.opus) echo "Title=$title
|
*.opus) echo "Title=$title
|
||||||
Artist=$artist
|
Artist=$artist
|
||||||
Album=$album
|
Album=$album
|
||||||
Track=$track
|
Track=$track
|
||||||
@ -54,8 +54,8 @@ Total=$total
|
|||||||
Date=$date
|
Date=$date
|
||||||
Genre=$genre
|
Genre=$genre
|
||||||
Comment=$comment" | opustags -i -S "$file" ;;
|
Comment=$comment" | opustags -i -S "$file" ;;
|
||||||
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
|
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
|
||||||
*.flac) echo "TITLE=$title
|
*.flac) echo "TITLE=$title
|
||||||
ARTIST=$artist
|
ARTIST=$artist
|
||||||
ALBUM=$album
|
ALBUM=$album
|
||||||
TRACKNUMBER=$track
|
TRACKNUMBER=$track
|
||||||
@ -63,5 +63,5 @@ TOTALTRACKS=$total
|
|||||||
DATE=$date
|
DATE=$date
|
||||||
GENRE=$genre
|
GENRE=$genre
|
||||||
DESCRIPTION=$comment" | metaflac --remove-all-tags --import-tags-from=- "$file" ;;
|
DESCRIPTION=$comment" | metaflac --remove-all-tags --import-tags-from=- "$file" ;;
|
||||||
*) echo "File type not implemented yet." ;;
|
*) echo "File type not implemented yet." ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
# If transmission-daemon is running, will ask to kill, else will ask to start.
|
# If transmission-daemon is running, will ask to kill, else will ask to start.
|
||||||
|
|
||||||
if pidof transmission-daemon >/dev/null ;
|
if pidof transmission-daemon > /dev/null; then
|
||||||
then
|
[ "$(printf 'No\nYes' | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled."
|
||||||
[ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled."
|
|
||||||
else
|
else
|
||||||
ifinstalled transmission-cli || exit
|
ifinstalled transmission-cli || exit
|
||||||
[ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
|
[ "$(printf 'No\nYes' | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
|
||||||
fi
|
fi
|
||||||
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||||
|
|||||||
@ -4,13 +4,12 @@
|
|||||||
# I have vim run this file whenever I exit a .tex file.
|
# I have vim run this file whenever I exit a .tex file.
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*.tex)
|
*.tex)
|
||||||
file=$(readlink -f "$1")
|
file=$(readlink -f "$1")
|
||||||
dir=$(dirname "$file")
|
dir=$(dirname "$file")
|
||||||
base="${file%.*}"
|
base="${file%.*}"
|
||||||
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyg|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete
|
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyg|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete
|
||||||
rm -rdf "$dir/_minted-$(basename -- $base)"
|
rm -rdf "$dir/_minted-$(basename -- $base)"
|
||||||
;;
|
;;
|
||||||
*) printf "Give .tex file as argument.\\n" ;;
|
*) printf 'Give .tex file as argument.\n' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
ifinstalled tremc-git transmission-cli || exit
|
ifinstalled tremc-git transmission-cli || exit
|
||||||
|
|
||||||
! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
|
! pidof transmission-daemon > /dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
|
||||||
|
|
||||||
$TERMINAL -e tremc; pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
$TERMINAL -e tremc
|
||||||
|
pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"
|
||||||
|
|||||||
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
# transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep.
|
# transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep.
|
||||||
|
|
||||||
pidof transmission-daemon >/dev/null || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}")
|
pidof transmission-daemon > /dev/null || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}")
|
||||||
|
|
||||||
transmission-remote -a "$@" && notify-send "🔽 Torrent added."
|
transmission-remote -a "$@" && notify-send "🔽 Torrent added."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user