about summary refs log tree commit diff stats
path: root/home-manager/packages/scripts/apps/deprecated
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/packages/scripts/apps/deprecated')
-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
4 files changed, 448 insertions, 0 deletions
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