aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/compile64
-rwxr-xr-xscripts/compresspdf5
-rwxr-xr-xscripts/dlmusic13
-rwxr-xr-xscripts/getibusinput11
-rwxr-xr-xscripts/music12
-rwxr-xr-xscripts/mute31
-rwxr-xr-xscripts/prepare9
7 files changed, 145 insertions, 0 deletions
diff --git a/scripts/compile b/scripts/compile
new file mode 100755
index 0000000..f038562
--- /dev/null
+++ b/scripts/compile
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+# A script to compile any (here defined) type of text file to a target format
+# Depends on: bash, basename, pdflatex
+# By David Penkowoj, 2021/08/02
+
+# Function to compile .lp to .pdf files
+LP_TO_PDF() {
+ lilypond "$1" --pdf -s -o "$2.pdf" &&
+ printf "Successfully compiled %s to %s\n" "$1" "$2.pdf" ||
+ printf "[ Error ] Couldn't compile %s\n" "$1"
+}
+
+# Function to compile .md to .pdf files
+MD_TO_PDF() {
+ pandoc "$1" -o "$2.pdf" &&
+ printf "Successfully compiled %s to %s\n" "$1" "$2.pdf" ||
+ printf "[ Error ] Couldn't compile %s\n" "$1"
+}
+
+# Function to compile .tex to .pdf files without making a mess
+TEX_TO_PDF() {
+ printf "If the script seems to hang, try pressing <Enter>\n"
+
+ pdflatex "$1" > /dev/null &&
+ pdflatex "$1" > /dev/null && # This is to ensure certain tex elements being drawn
+ rm -rf "$2.toc" "$2.log" "$2.aux" &&
+ printf "Successfully compiled %s to %s\n" "$2.tex" "$2.pdf" ||
+ printf "[ Error ] Couldn't compile %s\n" "$2.tex"
+}
+
+# Check if file exists
+if [[ -e "$1" ]]; then
+ # Determine filename and extension
+ FILENAME="$(basename -- "$1")"
+ EXTENSION="${FILENAME##*.}"
+
+ # Check if there is a extension at all
+ if [[ "$FILENAME" == "$EXTENSION" ]]; then
+ printf "[ Error ] The specified file has no extension\n"
+ exit 1
+ fi
+
+ # Do the respective compile actions
+ case "$EXTENSION" in
+ "tex")
+ TEX_TO_PDF "$1" "${FILENAME%.*}"
+ ;;
+ "md")
+ MD_TO_PDF "$1" "${FILENAME%.*}"
+ ;;
+ "lp")
+ LP_TO_PDF "$1" "${FILENAME%.*}"
+ ;;
+ "pov")
+ povray "$1"
+ ;;
+ *)
+ printf "[ Error ] There is no entry on how to handle '%s' files.\n" "$EXTENSION"
+ exit 1
+ esac
+fi
+
+exit 0
diff --git a/scripts/compresspdf b/scripts/compresspdf
new file mode 100755
index 0000000..704f2eb
--- /dev/null
+++ b/scripts/compresspdf
@@ -0,0 +1,5 @@
+#!/bin/bash
+# PDF Compressor
+# Dependencies: ghostscript
+
+[[ -e $1 ]] && gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile="${1}_compressed.pdf" "$1" && printf "done" || printf "error"
diff --git a/scripts/dlmusic b/scripts/dlmusic
new file mode 100755
index 0000000..aeda290
--- /dev/null
+++ b/scripts/dlmusic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# A script to not make me type all that argument **** when I want to download music.
+# Yes I am lazy.
+
+if [ "$1" ]
+then
+ youtube-dl "$1" --extract-audio -i -o "%(title)s.%(ext)s" --audio-format mp3
+ exit 0
+else
+ printf "[ Error ] Not enough arguments.\n"
+ exit 1
+fi
diff --git a/scripts/getibusinput b/scripts/getibusinput
new file mode 100755
index 0000000..4d52273
--- /dev/null
+++ b/scripts/getibusinput
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+STRING="$(ibus read-config | grep -o engines-order:.* | sed 's/engines-order: \[\|\]\|,//g' | awk '{ print $1 }')"
+
+if [[ "$STRING" == "'xkb:de::deu'" ]]; then
+ echo "DE"
+elif [[ "$STRING" == "'anthy'" ]]; then
+ echo "JA"
+elif [[ "$STRING" == "'xkb:de:ru:rus'" ]]; then
+ echo "RU"
+fi
diff --git a/scripts/music b/scripts/music
new file mode 100755
index 0000000..54104b0
--- /dev/null
+++ b/scripts/music
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+STATE="$(mpc | grep -o playing)"
+NAME="$(mpc current | xargs -i basename '{}')"
+VOLUME="$(mpc volume | awk '{print $2}')"
+
+if [[ -n "$STATE" ]]; then
+ echo "MPD Playing: ${NAME%.*} ($VOLUME)"
+else
+ echo "MPD Paused"
+fi
+
diff --git a/scripts/mute b/scripts/mute
new file mode 100755
index 0000000..1103c0e
--- /dev/null
+++ b/scripts/mute
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+SOURCE="alsa_input.usb-R__DE_Microphones_R__DE_NT-USB_Mini_610BAACA-00.mono-fallback"
+
+if [[ "$1" == "shortstatus" ]]; then
+ VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)"
+
+ if [[ "$VOLUME" == "0%" ]]; then
+ echo "OFF"
+ else
+ echo "ON"
+ fi
+
+ exit
+fi
+
+if [[ "$1" == "status" ]]; then
+ NAME="$(pactl list sources | grep -o Description:.* | sed -n 's/Description: //g;2p')"
+ VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*%)"
+
+ echo "$NAME ($VOLUME)"
+
+ exit
+fi
+
+if [[ "$(pactl get-source-volume $SOURCE | grep -o [0-9]*%)" == "0%" ]]; then
+ pactl set-source-volume "$SOURCE" 70%
+else
+ pactl set-source-volume "$SOURCE" 0%
+fi
+
diff --git a/scripts/prepare b/scripts/prepare
new file mode 100755
index 0000000..bb6d231
--- /dev/null
+++ b/scripts/prepare
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# sudo networkctl up enp0s31f6
+# sudo dhcpcd enp0s31f6
+
+xset -dpms
+xset s noblank
+xset s off
+