aboutsummaryrefslogtreecommitdiffstats
path: root/home-manager/packages/scripts/apps
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/packages/scripts/apps')
-rwxr-xr-xhome-manager/packages/scripts/apps/aumo53
-rwxr-xr-xhome-manager/packages/scripts/apps/con2pdf101
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR)87
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/config147
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR)40
-rwxr-xr-xhome-manager/packages/scripts/apps/deprecated/walldl174
6 files changed, 602 insertions, 0 deletions
diff --git a/home-manager/packages/scripts/apps/aumo b/home-manager/packages/scripts/apps/aumo
new file mode 100755
index 00000000..863dcf32
--- /dev/null
+++ b/home-manager/packages/scripts/apps/aumo
@@ -0,0 +1,53 @@
+#!/bin/sh
+# shellcheck disable=SC2046,2086
+
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+if [ "$1" = "-u" ];then udisksctl unmount -b $(cat $HOME/.cache/aumo/mnt_disk); exit 0; fi
+all_available_disks=$(mktemp)
+awk '{print $4}' /proc/partitions | sed '1 s|.*||' > "$all_available_disks"
+
+mounted_disk=$(mktemp)
+awk '{print $1}' /proc/mounts > "$mounted_disk"
+
+unmounted_disks=$(mktemp)
+
+for i in $(cat $all_available_disks);do
+ if ! grep -qw "/dev/$i" $mounted_disk && ! ls /sys/block/$i/*/partition > /dev/null 2> /dev/null;then echo $i >> $unmounted_disks;fi
+done
+
+
+u=1
+disk=-1
+while [ $disk -lt 0 ] || [ $disk -gt $(wc -l $unmounted_disks | awk '{print $1}') ];do
+
+ [ "$1" = "-v" ] && for i in $(cat $unmounted_disks);do
+ sudo fdisk -l "/dev/$i"
+ done
+
+ for i in $(cat $unmounted_disks);do
+ printf "%4s) %s\n" "$u" "$i"
+ u=$(( u + 1 ))
+ done
+
+ printf "%4s) Exit\n" "0"
+ printf "Input number: "
+ read -r disk
+
+ [ $disk -lt 0 ] || [ $disk -gt $(wc -l $unmounted_disks | awk '{print $1}') ] && printf "Wrong number. Please retry\n"
+ [ $disk -eq 0 ] && exit 0
+done
+
+mnt_disk="/dev/$(awk -v n=$disk 'NR==n' $unmounted_disks)"
+
+if ! [ "$1" = "-v" ] && [ -n "$1" ];then sudo mount "$mnt_disk" "$1" && exit 0;fi
+[ -n "$2" ] && sudo mount "$mnt_disk" "$1" && exit 0
+if mount | grep -q ~/mnt ;then dien "Something is mounted at ~/mnt";else udisksctl mount -b "$mnt_disk";fi
+
+[ -e $HOME/.cache/aumo/mnt_disk ] || mkdir -p $HOME/.cache/aumo
+echo $mnt_disk >> $HOME/.cache/aumo/mnt_disk
+rm $all_available_disks
+rm $mounted_disk
+rm $unmounted_disks
+[ -d /tmp/LIB_FILE_TEMP_DIR/ ] && rm -r /tmp/LIB_FILE_TEMP_DIR/
diff --git a/home-manager/packages/scripts/apps/con2pdf b/home-manager/packages/scripts/apps/con2pdf
new file mode 100755
index 00000000..7d23fe82
--- /dev/null
+++ b/home-manager/packages/scripts/apps/con2pdf
@@ -0,0 +1,101 @@
+#! /bin/sh
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+
+# Vars
+counter=0;
+a_set=false;
+pw=$(pwd)
+
+usage() {
+ cat << EOF
+ This is a help doc!
+ -p for path
+ -h for help
+ -n for name
+ -g gen pdf dir
+ -r for number of pages per pdf
+EOF
+exit 0;
+}
+
+# Ops
+while getopts ":hp:n:gr:" flag;do
+ case "$flag" in
+ p)
+ Command_path=$OPTARG
+ ;;
+ n)
+ name=$OPTARG
+ ;;
+ g)
+ gen=true
+ ;;
+ r)
+ pages=$OPTARG
+ ;;
+ h)
+ usage;;
+ *)
+ usage;;
+
+ esac
+ done
+[ -z "$pages" ] && die "No pages set"
+
+
+# Scan
+if [ -z $Command_path ];then
+ tm=$(mktemp -d)
+ cd $tm || die "Bug"
+
+ for i in $(seq $pages);do
+ scanimage --format=tiff --progress \
+ --source ADF --device="airscan:w1:Brother DCP-9022CDW" \
+ --batch=%d.tif --batch-increment=$pages --batch-start=$i
+ [ $? -ne 0 ] && scanimage --format=tiff --progress \
+ --source ADF --device="airscan:w1:Brother DCP-9022CDW" \
+ --batch=%d.tif --batch-increment=$pages --batch-start=$i
+ if [ $pages -ge 2 ];then
+ msg "Finished first turn, please change side!";
+ readp "Ready to continue?" noop
+ fi
+ done
+else
+ tm=$Command_path;
+fi
+cd $pw || die "Bug"
+
+# mk pdf
+if [ "$gen" = true ];then
+ mkdir pdfs
+ cd pdfs/ || die "Bug"
+fi
+
+while IFS= read -r i;do
+
+ if [ $pages -ge 2 ];then
+ a_set=false;
+ if [ -z "$a" ];then
+ a="$i"
+ a_set=true;
+ : $((counter += 1))
+ fi
+
+ if [ -n "$a" ] && ! [ "$a_set" = true ];then
+ convert "$a" "$i" -compress jpeg -quality 70 "$name"_"$counter".pdf
+ a=
+ fi
+ else
+ : $((counter += 1))
+ convert "$i" -compress jpeg -quality 70 "$name"_"$counter".pdf
+ fi
+
+
+done < "$(tmp "ls $tm | sort -n | awk -v a=$tm -v c='/' '{printf a} {printf c} {print \$0}' ")"
+
+
+rm -r $tm
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR) b/home-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR)
new file mode 100755
index 00000000..023a2bbf
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/riR/compare_all_files(has_been_riR)
@@ -0,0 +1,87 @@
+#! /bin/bash
+
+tmp=$(mktemp)
+tmp2=$(mktemp)
+pstr="[=======================================================================]"
+printf "Path to filter: "
+read path
+
+## USE FIND INSTEAD OF LS
+cd $path
+results
+echo "" > results
+
+declare weirdchars=" &\'"
+
+function normalise_and_rename() {
+ declare -a list=("${!1}")
+ for fileordir in "${list[@]}";
+ do
+ newname="${fileordir//[${weirdchars}]/_}"
+ [[ ! -a "$newname" ]] && \
+ mv "$fileordir" "$newname" || \
+ echo "Skipping existing file, $newname."
+ done
+}
+
+declare -a dirs files
+
+while IFS= read -r -d '' dir; do
+ dirs+=("$dir")
+done < <(find -type d -print0 | sort -z)
+
+normalise_and_rename dirs[@]
+
+while IFS= read -r -d '' file; do
+ files+=("$file")
+done < <(find -type f -print0 | sort -z)
+
+normalise_and_rename files[@]
+
+find $path > $tmp
+total=$(cat $tmp | wc -l)
+#ls -RAx1 --group-directories-first $path | awk NF | awk ' !/\//' > $tmp
+#cat $tmp
+#exit
+for ((i = 1; i <= $(cat $tmp | wc -l); i++))
+do
+ FILE1=$(cat $tmp | awk -v n=$i 'NR == n {printf $0}')
+ printf "\r%3d.%1d%% %.${pd}s" $(( $i * 100 / $total )) $(( ($i * 1000 / $total) % 10 )) $pstr
+ if [ -d ${FILE1} ]; then
+ printf '%s is a Directory\n' "$FILE1"
+ else
+ echo ${FILE1} >> $tmp2
+ fi
+done
+echo "##########################################################################################################################################"
+echo "changing to search"
+total=$(cat $tmp2 | wc -l)
+
+for ((i = 1; i <= $(cat $tmp2 | wc -l); i++))
+do
+ FILE1=$(cat $tmp2 | awk -v n=$i 'NR == n {printf $0}')
+ printf "total : %3d.%1d%% %.${pd}s\n" $(( $i * 100 / $total )) $(( ($i * 1000 / $total) % 10 )) $pstr
+
+ for ((x = 1; x <= $(cat $tmp2 | wc -l); x++))
+ do
+ FILE2=$(cat $tmp2 | awk -v n=$x 'NR == n {printf $0}')
+ printf "\r%3d.%1d%% %.${pd}s" $(( $x * 100 / $total )) $(( ($x * 1000 / $total) % 10 )) $pstr
+ if [ $x -eq $i ]; then
+ ((x=x+1))
+ FILE2=$(cat $tmp2 | awk -v n=$x 'NR == n {printf $0}')
+ elif [ $(wc -c $FILE2 | awk '{print $1}') != $(wc -c $FILE1 | awk '{print $1}') ]; then
+ :
+ else
+ if cmp --silent "$FILE1" "$FILE2"; then
+ printf ' %s \n' "$FILE2" >> results
+
+ fi
+ fi
+ done
+done
+echo
+echo "#########################################################################"
+
+cat $dir
+rm $tmp
+rm $tmp2
diff --git a/home-manager/packages/scripts/apps/deprecated/riR/config b/home-manager/packages/scripts/apps/deprecated/riR/config
new file mode 100755
index 00000000..b5607a16
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/riR/config
@@ -0,0 +1,147 @@
+#!/bin/sh
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+git_repo_home="$XDG_CONFIG_HOME"/git_repo
+[ -d "$git_repo_home" ] || mkdir "$git_repo_home"
+launch_dir="$(dirname "$(readlink -f "$0")")"
+
+. "$launch_dir"/utils
+
+add() {
+ name=$(basename "$1")
+ while clean files | awk '{print $1}' | grep -w "^$name$" > /dev/null;do
+ printf "\"%s\" already exists, new name for link: " "$name"
+ read -r name
+ done
+ cp "$1" "$git_repo_home"/"$name"
+ {
+ printf "%s " "$name";
+ printf "%s " "$1";
+ printf "%s\n" "$(stat -c "%a" "$1")"
+ } >> "$git_repo_home"/files
+}
+
+remove() {
+ tmp=$(grepw "$1")
+ if pre_check "$tmp";then
+ file_path="$(awk '{print $2}' "$tmp")"
+ file_name="$(awk '{print $1}' "$tmp")"
+
+ rm "$git_repo_home"/"$file_name"
+ grep -v "$1" "$git_repo_home"/files > "$tmp"
+ cat "$tmp" > "$git_repo_home"/files
+ fi
+}
+
+gitw() {
+ git --git-dir="$git_repo_home"/.git --work-tree="$git_repo_home" "$@"
+}
+
+deploy_files() {
+ tmp=$(grepw "$1")
+ if pre_check "$tmp";then
+ file_path="$(awk '{print $2}' "$tmp")"
+ file_name="$(awk '{print $1}' "$tmp")"
+ file_bits="$(awk '{print $3}' "$tmp")"
+
+ if [ -e "$file_path" ] && ! cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ if overwrite_check "$file_path" "$file_name" "file" ;then
+ cp -f "$git_repo_home"/"$file_name" "$file_path"
+ fi
+ elif cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ [ "$AUTO_GEN" = "Y" ] || msg "File is already deployed"
+ else
+ cp "$git_repo_home"/"$file_name" "$file_path"
+ chmod "$file_bits" "$file_path"
+ fi
+ fi
+}
+
+update() {
+ tmp=$(grepw "$1")
+ if pre_check "$tmp";then
+ file_path="$(awk '{print $2}' "$tmp")"
+ file_name="$(awk '{print $1}' "$tmp")"
+
+ if [ -e "$file_path" ] && ! cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ if overwrite_check "$file_path" "$file_name" "backup" ;then
+ cp -f "$file_path" "$git_repo_home"/"$file_name"
+ fi
+ elif cmp "$git_repo_home"/"$file_name" "$file_path" > /dev/null;then
+ [ "$AUTO_GEN" = "Y" ] || msg "File does not need to be updated"
+ else
+ die "File does not exist on the system!"
+ fi
+ fi
+}
+
+usage() {
+ cat << EO
+This is config, an easy dotfiles backup service!
+
+help Outputs this help
+add Adds the specified files
+remove Removes the specified files
+commit Same as 'config git commit'
+git Runs git with the arguments in the backup directory
+deploy Copies the specified file, or all files to their location
+dump Dumps the 'files' file
+update Updates the specified file, or all files if none are supplied
+grep Searches for the supplied string in the 'files' file
+EO
+exit "$1"
+}
+
+case "$1" in
+ "help")
+ shift 1
+ usage 0
+ ;;
+ "add")
+ shift 1
+ while [ "$1" != "" ];do
+ add "$(readlink -f "$1")"
+ shift 1
+ done
+ ;;
+ "remove")
+ shift 1
+ shift_througth "remove" "$@"
+ ;;
+ "commit")
+ shift 1
+ gitw commit
+ ;;
+ "git")
+ shift 1
+ gitw "$@"
+ ;;
+ "deploy")
+ shift 1
+ shift_througth "deploy_files" "$@"
+ ;;
+ "dump")
+ shift 1
+ cat "$git_repo_home"/files
+ ;;
+ "update")
+ shift 1
+ shift_througth "update" "$@"
+ ;;
+ "grep")
+ shift 1
+ tmp=$(grepw "$1")
+ cat "$tmp"
+ ;;
+ *)
+ echo "Option $1 not recognized!"
+ usage 1
+ ;;
+
+ esac
+
+
+
+
+ if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR) b/home-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR)
new file mode 100755
index 00000000..8a216b6b
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/riR/lf-move-fill(has_been_riR)
@@ -0,0 +1,40 @@
+#!/bin/sh
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. ~/.local/lib/shell/lib
+
+tmp=$(mktemp);
+out=$(mktemp);
+clean $XDG_CONFIG_HOME/lf/rel_dirs > $tmp;
+
+get_hot_key() {
+ printf g
+ if ! [ "$i" = "$(readlink -f "$(cat $tmp | sed -n -e ${a}p)")" ];then
+ printf "%s" "$(basename "$(cat $tmp | sed -n -e ${a}p)" | cut -c 1)"; # i.e. /home/dt/school
+ fi
+ #if ! [ "$(realpath i)" = "$(cat $tmp | sed -n -e ${a}p)" ];then
+ # i = /home/dt/school/informatik
+ printf "%s" "$(basename $i | cut -c 1)";
+ printf "%s" "$(basename $i | cut -c 2)";
+ #fi
+ if [ $i = "$(cat $tmp | sed -n -e ${1}p)" ];then
+ printf '.';
+ fi
+
+}
+
+
+for a in $(seq "$(cat $tmp | wc -l )");do
+ echo $a >> $out;
+
+ while IFS= read -r i;do
+ printf "map %s cd %s\n" "$(get_hot_key "$a")" "$i" >> $out;
+ done < "$(tmp find "$(cat $tmp | sed -n -e ${a}p)" -maxdepth 1)"
+ echo >> $out;
+done
+
+cat $out # | awk '{print $2}' | sort | uniq -d;
+
+rm $tmp;
+rm $out;
+if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
diff --git a/home-manager/packages/scripts/apps/deprecated/walldl b/home-manager/packages/scripts/apps/deprecated/walldl
new file mode 100755
index 00000000..3b6752db
--- /dev/null
+++ b/home-manager/packages/scripts/apps/deprecated/walldl
@@ -0,0 +1,174 @@
+#!/bin/bash
+############################################################
+# Help #
+############################################################
+Help()
+{
+ # Display Help
+ echo "Fetch all images accociated with a given URL."
+ echo
+ echo "options:"
+ echo "-h Print this Help."
+ echo "-H For Sites with hrefs"
+ echo "-L For Sites without hrefs"
+ echo "-C For generated Code"
+ echo
+}
+
+############################################################
+############################################################
+# Main program #
+############################################################
+############################################################
+############################################################
+# Create all needed tmp files and variables. #
+############################################################
+Tav() {
+ pstr="[=======================================================================]"
+ out="$(mktemp)"
+ html="$(mktemp)"
+ NR="$(mktemp)"
+ printf "URL for Website: "
+ read url
+ dir=$(echo "$url" | awk '{ gsub(":|https",""); print $0 }')
+ try=HighRes
+}
+############################################################
+# Define downloader engines #
+############################################################
+HighRes() {
+ # For Websites that have hrefs for bigger images
+ curl -sS $url | awk 'BEGIN { FS="\"";} /href=/ && /img src/ && !/index.html/ { print $2 } ' | awk '!a[$0]++' | sort > $out
+}
+LowRes() {
+ # For Websites that don't have hrefs
+ wget --quiet --output-document=${html} $url
+ cat $html | tidy --custom-tags pre --show-warnings no -q -output $html
+ cat $html | awk 'BEGIN { FS="\"";} /src=/ {print $2}' > $out
+}
+GenCode() {
+ # For Generated Code blocks
+ wget --quiet --output-document=${html} $url
+ cat $html | tidy --custom-tags pre --show-warnings no -q -output $html
+
+ cat $html | awk ' /<img/ {print NR}' > $NR
+ for ((i = 1; i <= $(cat $NR | wc -l); i++))
+ do
+ lnNums=$(cat $NR | awk -v n=$i ' NR == n {print $0} ')
+ let "lnNums++"
+ cat $html | awk -v n=$lnNums 'BEGIN { FS="\"";} NR == n { print $2 } ' >> $out
+ done
+}
+############################################################
+# Process the input options. Add options as needed. #
+############################################################
+# Get the options
+while getopts ":hHLGV" option; do
+ case $option in
+ H)
+ proc=HighRes
+ ;;
+ L)
+ proc=LowRes
+ ;;
+ G)
+ proc=GenCode
+ ;;
+ V)
+ ver=true
+ ;;
+ \?) # Invalid option
+ echo "Error: Invalid option"
+ ;;
+ * | h)
+ Help
+ exit;;
+ esac
+done
+############################################################
+# Download it #
+############################################################
+Down() {
+ total=$(cat $out | wc -l)
+ if [ $total -eq 0 ];
+ then
+ case $try in
+ HighRes)
+ if [ ver ];
+ then
+ echo "trying HighRes engine"
+ fi
+ HighRes
+ try="GenCode"
+ Down
+ ;;
+ LowRes)
+ if [ ver ];
+ then
+ echo "trying LowRes engine"
+ fi
+ LowRes
+ try=":("
+ Down
+ ;;
+ GenCode)
+ if [ ver ];
+ then
+ echo "trying GenCode engine"
+ fi
+ GenCode
+ try="LowRes"
+ Down
+ ;;
+ *)
+ echo "Nothing found"
+ exit
+ ;;
+ esac
+
+ else
+ cat $out
+ read -p "Do you want to download this to ${WALLPAPERDIR}/${dir}?(y/n) " -n 1 -r
+ echo
+
+ if [[ $REPLY =~ ^[Yy]$ ]];
+ then
+ mkdir -p ${WALLPAPERDIR}/${dir}
+ cd ${WALLPAPERDIR}/${dir}
+ url=$(echo $url | awk ' BEGIN {FS="/";} {printf "%s//%s/", $1, $3 } ' )
+ # cycle throught all pictures and download them
+ for ((i = 0; i <= $total; i++ ))
+ do
+ awk -v n=$i 'FNR == n ' ${out} | xargs printf "$url%s\n" | xargs curl -OsS
+ pd=$(( $i * 73 / $total ))
+ printf "\r%3d.%1d%% %.${pd}s" $(( $i * 100 / $total )) $(( ($i * 1000 / $total) % 10 )) $pstr
+ done
+ printf "\n"
+ echo "downloaded to ${WALLPAPERDIR}${dir}"
+ rm -f "$out"
+ rm -f "$html"
+ rm -f "$NR"
+ fi
+ fi
+}
+############################################################
+# Call the functions #
+############################################################
+
+Tav
+# case $proc in
+# HighRes)
+# HighRes
+# ;;
+# LowRes)
+# LowRes
+# ;;
+# GenCode)
+# GenCode
+# ;;
+# *)
+# echo "No engine specified"
+# exit
+# ;;
+# esac
+Down