Browse Source

update brighness scripts + update compile script

Noah Vogt 3 years ago
parent
commit
4c30f8aed4
5 changed files with 31 additions and 11 deletions
  1. 3 2
      local-bin/brightness
  2. 1 1
      local-bin/brightness-save
  3. 25 6
      local-bin/compile
  4. 1 1
      local-bin/dec-brightness
  5. 1 1
      local-bin/inc-brightness

+ 3 - 2
local-bin/brightness

@@ -5,10 +5,11 @@
 #printf "🔆 %s%%\\n" "$(xbacklight -get | sed 's/\..*$//')"
 #printf "🔆 %s%%\\n" "$(xbacklight -get | sed 's/\..*$//')"
 #exit
 #exit
 
 
-device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +3 | awk '{print $2}' | tr -d "'")
+device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +2 | awk '{print $2}' | tr -d "'")
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
     device="intel_backlight"
     device="intel_backlight"
 fi
 fi
 [ -z "$device" ] && { printf ""; exit; }
 [ -z "$device" ] && { printf ""; exit; }
 
 
-printf "🔆 %s\\n" "$(brightnessctl -d "${device}" | grep Current | awk -F '[)(]' '{print $2}')"
+printf "%s" "$(brightnessctl -d "${device}" | grep Current | \
+    awk -F '[)(]' '{print $2}' | sed 's/%$//')"

+ 1 - 1
local-bin/brightness-save

@@ -2,7 +2,7 @@
 
 
 # script to save the brightness state so it is the same after a restart
 # script to save the brightness state so it is the same after a restart
 
 
-device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +3 | awk '{print $2}' | tr -d "'")
+device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +2 | awk '{print $2}' | tr -d "'")
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
     device="intel_backlight"
     device="intel_backlight"
 fi
 fi

+ 25 - 6
local-bin/compile

@@ -4,19 +4,38 @@
 
 
 [ -z "$1" ] && { echo "Error: Usage: compile [filename]"; exit 1; }
 [ -z "$1" ] && { echo "Error: Usage: compile [filename]"; exit 1; }
 
 
+file=$(readlink -f "$1")
+dir=${file%/*}
+base="${file%.*}"
+ext="${file##*.}"
+
 choosepandoc() {
 choosepandoc() {
     [ -z "$template" ] && template="$(ls $HOME/.config/setup/templates/pandoc/* | \
     [ -z "$template" ] && template="$(ls $HOME/.config/setup/templates/pandoc/* | \
         sed 's/.*\///g' | dmenu -i -l 30 -p "choose pandoc template: ")"
         sed 's/.*\///g' | dmenu -i -l 30 -p "choose pandoc template: ")"
     [ -z "$newext" ] && newext="$(echo "$template" | sed 's/.*\.//; s/latex/pdf/;')"
     [ -z "$newext" ] && newext="$(echo "$template" | sed 's/.*\.//; s/latex/pdf/;')"
 }
 }
 
 
-base=${1%.*}
-ext=${1##*.}
+textype() { \
+	command="pdflatex"
+	( head -n5 "$file" | grep -qi 'xelatex' ) && command="xelatex"
+	( head -n5 "$file" | grep -qi 'lualatex' ) && command="lualatex"
+	$command --output-directory="$dir" "$base" &&
+	grep -qi addbibresource "$file" &&
+	biber --input-directory "$dir" "$base" &&
+	$command --output-directory="$dir" "$base" &&
+	$command --output-directory="$dir" "$base"
+}
 
 
 case "$ext" in
 case "$ext" in
-    ms) preconv "$1" |  groff -"$ext" -dpaper=a4 -P -pa4 -T pdf > "$base.pdf" && pkill -HUP mupdf;;
-    tex) pdflatex "$1"; pkill -HUP mupdf;;
-    md) choosepandoc; pandoc -V "fontsize=16pt" -s "$1" --template="$HOME/.config/setup/templates/pandoc/$template" -V "fontsize=16pt" -o "$base.$newext"; pkill -HUP mupdf;;
-    rmd) pandoc -s "$1" --template="$HOME/.config/setup/templates/pandoc/german.latex" -o "$base.pdf"; pkill -HUP mupdf;;
+    ms) preconv "$file" |  groff -"$ext" -dpaper=a4 -P -pa4 -T pdf > "$base.pdf" && pkill -HUP mupdf;;
+    md) choosepandoc; pandoc -V "fontsize=16pt" -s "$file" --template="$HOME/.config/setup/templates/pandoc/$template" -V "fontsize=16pt" -o "$base.$newext"; pkill -HUP mupdf;;
+    rmd) pandoc -s "$file" --template="$HOME/.config/setup/templates/pandoc/german.latex" -o "$base.pdf"; pkill -HUP mupdf;;
+	py) python "$file" ;;
+	[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
+	rs) cargo build ;;
+	sass) sassc -a "$file" "$base.css" ;;
+	scad) openscad -o "$base".stl "$file" ;;
+	sent) setsid -f sent "$file" 2>/dev/null ;;
+	tex) textype "$file"; pkill -HUP mupdf ;;
     *) echo "Error: unknown file extension '$ext'"; exit 1;#;
     *) echo "Error: unknown file extension '$ext'"; exit 1;#;
 esac
 esac

+ 1 - 1
local-bin/dec-brightness

@@ -8,7 +8,7 @@
 #exit
 #exit
 
 
 # get brightness device
 # get brightness device
-device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +3 | awk '{print $2}' | tr -d "'")
+device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +2 | awk '{print $2}' | tr -d "'")
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
     device="intel_backlight"
     device="intel_backlight"
 fi
 fi

+ 1 - 1
local-bin/inc-brightness

@@ -8,7 +8,7 @@
 #exit
 #exit
 
 
 # get brightness device
 # get brightness device
-device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +3 | awk '{print $2}' | tr -d "'")
+device=$(brightnessctl -l | grep "class 'backlight'" | tail -n +2 | awk '{print $2}' | tr -d "'")
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
 if brightnessctl -l | grep "class 'backlight'" | grep -q "^Device 'intel_backlight'"; then
     device="intel_backlight"
     device="intel_backlight"
 fi
 fi