diff --git a/compare.sh b/compare.sh deleted file mode 100755 index 025453d..0000000 --- a/compare.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -if [[ $# -lt 2 ]]; then - echo "Usage: $0 [del]" - exit 1 -fi - -dir1="$1" -dir2="$2" - -find "$dir1" -mindepth 2 -maxdepth 2 -type d -printf '%P\n' | -while IFS= read -r rel; do - if [[ -d "$dir2/$rel" ]]; then - # Exists in both - if [[ "$3" == "del" ]]; then - echo "Deleting: $dir1/$rel" - rm -rf -- "$dir1/$rel" - - # Remove empty author directory - author="${rel%%/*}" - rmdir --ignore-fail-on-non-empty "$dir1/$author" 2>/dev/null - fi - else - # Only exists in $1 - echo "$rel" - fi -done diff --git a/copy.sh b/copy.sh deleted file mode 100755 index 6b3b9b6..0000000 --- a/copy.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -USER="lucas" -DEST="~/Downloads" - -get_config() { -while [[ ${1:0:1} == - ]]; do - echo "Param: $1" - [[ $1 == -h ]] && { - if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi - HOST="$2" - shift 2; - continue; - }; - [[ $1 == -f ]] && { - if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi - file="$2" - shift 2; - continue; - }; - [[ $1 == -o ]] && { - if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi - opt="$2" - shift 2; - continue; - }; - [[ $1 == -d ]] && { - if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi - DEST="$2" - shift 2; - continue; - }; - [[ $1 == -p ]] && { - DEST="~/Videos/.stuff" - shift 1; - continue; - }; - [[ $1 == --help ]] && { - usage - exit - }; - echo "Parameter $1 discarded" - usage - exit -done -} -usage() { - printf "Usage: - -h \tRemote Hostname - -f \tPath of local file - -o \tGive additional Options - -d \tChoose other Destination Folder - -p\t\tChange Destination - --help\t\tDisplay Usage\n" - exit -} -get_config "$@" -if [ "${HOST}" == "deluge" ]; then - HOST="serverhost" - USER="deluge-user" - DEST="/home/deluge-user/Downloads/Torrents/" -fi -echo "Copy ${file} to ${HOST}:${DEST}" -scp -r ${opt} "${file}" ${USER}@${HOST}:${DEST} diff --git a/copymotd.sh b/copymotd.sh deleted file mode 100755 index 157ffe0..0000000 --- a/copymotd.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -scp lucas@serverhost:/etc/update-motd.d/10-help-text ~/Documents/Dokumente/Dokumente/Projekte/Server/motd.serverhost.10-help-text -scp lucas@raspberry:~/.profile ~/Documents/Dokumente/Dokumente/Projekte/Server/motd.raspberry.profile -rm 0 diff --git a/cron.sh b/cron.sh deleted file mode 100755 index d013ef2..0000000 --- a/cron.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/expect -f -#Copy Crontab of raspberry and serverhost -set host "raspberry" -array set user { 0 "root" 1 "lucas"} -set port "1160" -for {set j 0} {$j < 2} {incr j 1} { - spawn ssh -p $port lucas@$host - expect { - "No route to host" { - puts "spawn ssh -p $port SendEnv=TERM lucas@$host failed." - exit 0 - } - "Login Sucsessfull" { - if {$user($j)=="root"} { - send "sudo crontab -l >> crontab.buf\r" - expect "lucas: " - send "Gina\&1994\&Nonna\r" - } else { - send "crontab -l >> crontab.buf\r" - } - #expect "$ " - #send "cat crontab.buf\r" - expect "$ " - send "scp -P 3032 crontab.buf lucas@serverhost:~/Documents/Dokumente/Dokumente/Projekte/Server/crontab.$host.$user($j)\r" - expect "$ " - send "rm crontab.buf\r" - puts "crontab.$host.$user($j) created." - } - } -} diff --git a/cron_workhost.sh b/cron_workhost.sh deleted file mode 100755 index 0be8d8c..0000000 --- a/cron_workhost.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/expect -f -#Copy Crontab of raspberry and serverhost -array set host { 0 "serverhost" 1 "raspberry"} -array set user { 0 "root" 1 "lucas"} -array set port { 0 "3032" 1 "1160"} - -for {set i 0} {$i < 2} {incr i 1} { - for {set j 0} {$j < 2} {incr j 1} { - spawn ssh -p $port($i) lucas@$host($i) - expect { - "No route to host" { - puts "spawn ssh -p $port($i) lucas@$host($i) failed." - exit 0 - } - "Login Sucsessfull" { - if {$user($j)=="root"} { - send "sudo crontab -l >> crontab.buf\r" - expect "lucas: " - send "Gina\&1994\&Nonna\r" - } else { - send "crontab -l >> crontab.buf\r" - } - #expect "$ " - #send "cat crontab.buf\r" - expect "$ " - send "scp -P 1160 crontab.buf lucas@workhost:~/Documents/Dokumente/Dokumente/Projekte/Server/crontab.$host($i).$user($j)\r" - expect "$ " - send "rm crontab.buf\r" - puts "crontab.$host($i).$user($j) created." - } - } - } -} diff --git a/find.sh b/find.sh deleted file mode 100755 index 8ea3216..0000000 --- a/find.sh +++ /dev/null @@ -1 +0,0 @@ -find . -type f -name '*conflict**' -exec sh -c 'x="{}"; mv "$x" "$(echo "$x" | sed "s/ (conflicted copy 2025-01-06 190022)//g")" ' \; diff --git a/generatePatchesByFile.sh b/generatePatchesByFile.sh deleted file mode 100755 index 94aff11..0000000 --- a/generatePatchesByFile.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -commit1=$1 -commit2=$2 -dir=$3 -patches_dir=$4 -CHECK=1 -APPLY=1 - -if [ -z "$commit1" ] || [ -z "$commit2" ] || [ -z "$dir" ]; then - echo "Usage: $0 [patches_dir]" - exit 1 -fi - -# Default patches directory if not provided -if [ -z "$patches_dir" ]; then - patches_dir="$(pwd)/patches" -elif [[ "$patches_dir" != /* ]]; then - patches_dir="$(pwd)/${patches_dir}patches" -fi - -if [[ "$commit2" == "HEAD" ]]; then - commit2="" -fi - -echo "Diffing $dir from $commit1 to ${commit2:-HEAD}..." -echo "Patches will be saved in: $patches_dir" - - -# Save current directory -orig_dir="$(pwd)" - -# Get git root directory relative to $dir -git_root=$(git -C "$dir" rev-parse --show-toplevel) || { echo "Not a git repo: $dir"; exit 1; } - -# Compute relative path of $dir from git root -relative_dir=$(realpath --relative-to="$git_root" "$dir") -echo "Relative path of $dir from git root: $relative_dir" - -# Change to git root directory -cd "$git_root" || { echo "Failed to cd to git root of $dir"; exit 1; } -echo "Go to $git_root" -mkdir -p "$patches_dir" - -# Load list of changed files into an array -mapfile -t diff_files < <(git diff --name-only $commit1..$commit -- $relative_dir ) - - -for file in "${diff_files[@]}"; do - git diff $commit1..$commit2 --stat -- "$file" -done - -for file in "${diff_files[@]}"; do - echo $file - git diff $commit1..$commit2 -- "$file" > "$patches_dir/$(basename "$file").patch" -done -for patch in "$patches_dir"/*.patch; do - echo $patch - for patch in "$patches_dir"/*.patch; do - sed -i 's|trixel3_software/||g' "$patch" - done -done - -# Get git root directory relative to $dir -git_root_patches_dir=$(git -C "$patches_dir" rev-parse --show-toplevel) || { echo "Not a git repo: $patches_dir"; exit 1; } - -# Compute relative path of $dir from git root -relative_dir_patches_dir=$(realpath --relative-to="$git_root_patches_dir" "$patches_dir") -echo "Relative path of $patches_dir from git root: $relative_dir_patches_dir" - -# Change to git root directory -cd "$git_root_patches_dir" || { echo "Failed to cd to git root of $patches_dir"; exit 1; } -echo "Go to $git_root_patches_dir" - -if [[ $CHECK -eq 1 ]]; then - # check patches - echo "CHECK Patches" - for patch in "$patches_dir"/*.patch; do - echo $patch - git apply --check "$patch" - done -fi - -if [[ $APPLY -eq 1 ]]; then - # apply patches - echo "APPLY Patches" - for patch in "$patches_dir"/*.patch; do - if git apply "$patch"; then - echo "Applied $patch successfully." - rm "$patch" - else - echo "Failed to apply $patch. Skipping." - fi - done -fi - -# Return to original directory -cd "$orig_dir" || exit 1 diff --git a/hoststatus.sh b/hoststatus.sh deleted file mode 100755 index 14c9c34..0000000 --- a/hoststatus.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -if [ "$2" == "-c" ];then - blue="\e[34m" - red="\e[31m" - norm="\e[0m" -else - blue="" - red="" - norm="" -fi -declare -a hosts=("serverhost" "workhost" "quiethost" "localhost") -if [ "$#" -eq 0 ];then - printf "Arguments: hosts, netw\n" -fi -if [ "$1" == "hosts" ];then - for host in "${hosts[@]}"; do - ping -c 2 -W 1 $host > /dev/null - if [ $? -eq 0 ]; then - printf "%s\t\t[$blue UP$norm ]\n" "$host" | sed "s/localhost/$(hostname)/g" - else - printf "%s\t\t[$red DOWN$norm ]\n" "$host" - fi - done -elif [ "$1" == "netw" ];then - if [ "$(ifconfig | grep -A2 eth0 | grep inet)" != "" ]; then - if="eth0" - elif [ "$(ifconfig | grep -A2 wlan0 | grep inet)" != "" ]; then - if="wlan0" - fi - #netw="$(ifconfig $if | grep -m1 -o -P '(?<=inet ).*(?= netmask)' | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.')" - netw="$( ifconfig $if | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.' | grep -m1 -v 255)" - for i in {1..254}; do - ping -c 1 -W 1 $netw$i > /dev/null - if [ $? -eq 0 ]; then - # hostname="$(ssh 10.0.0.$i hostname)" - # if [ ! $? -eq 0 ]; then - hostname="$(nbtscan 10.0.0.$i | grep -A1 "\-\-\-\-\-" | sed 's/ */ /g' | cut -d' ' -f2 | grep '[A-Za-z]')" - # fi - printf "10.0.0.%s\t[$blue UP$norm ]\t%s\n" "$i" "$hostname" - fi - done -fi diff --git a/img_type.sh b/img_type.sh deleted file mode 100755 index 6a8f3aa..0000000 --- a/img_type.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -NEW_TYPE="png" -TYPE_ARR=("jp*g" "tif" "webp" "png") -file="" -folder="" -usage(){ - printf "Usage: - -f \tConvert single File - -d \tConvert all files in Dir - -t \tSet new Type - -h\t\tDisplay this\n" -} - -img_convert() { - IMG="$1" - IMG_NEW="$IMG" - for type in ${TYPE_ARR[@]}; do - IMG_NEW="$(echo ${IMG_NEW} | sed 's/\.'"${type}"'/.'"${NEW_TYPE}"'/g')" - done - if [ ! -f "${IMG}" ]; then - echo "${IMG} not found" - return - fi - if [ "${IMG}" == "${IMG_NEW}" ]; then - echo "${IMG} and ${IMG_NEW} are the same" - return - fi - echo "Convert ${IMG} ${IMG_NEW}" - convert -quiet "${IMG}" "${IMG_NEW}" >> /dev/null - rm "${IMG}" -} - -folder_magic(){ - IMG_FOLDER="$1" - echo "Convert Imgs in ${IMG_FOLDER}" - IMG_ARR=() - IMG_ARR_NEW=() - - IFS=$'\n'; set -f - for type in ${TYPE_ARR[@]}; do - if [[ "${type}" != "${NEW_TYPE}" ]]; then - IMG_ARR+=($(find ${IMG_FOLDER} -name "*${type}")) - IMG_ARR_NEW+=($(find ${IMG_FOLDER} -name "*${type}" | sed 's/\.'"${type}"'/.'"${NEW_TYPE}"'/g')) - fi - done - for ((i=0;i<${#IMG_ARR[@]};i++)); do - echo "Convert ${IMG_ARR[$i]} ${IMG_ARR_NEW[$i]}" - convert -quiet "${IMG_ARR[$i]}" "${IMG_ARR_NEW[$i]}" >> /dev/null - rm "${IMG_ARR[$i]}" - done -} - -get_config() { -if [ $# -eq 0 ] || [ ${1:0:1} != - ]; then - echo "Too few Arguments" - usage - exit -fi -while [[ ${1:0:1} == - ]]; do - echo "Param: $1" - [[ $1 == -h ]] && { - usage - exit - }; - [[ $1 == -f ]] && { - if [ $# -lt 2 ]; then - echo "Too few Arguments" - usage - exit - fi - file="$2"; - shift 2; - continue; - } - [[ $1 == -d ]] && { - if [ $# -lt 2 ]; then - echo "Too few Arguments" - usage - exit - fi - folder="$2"; - shift 2; - continue; - } - [[ $1 == -t ]] && { - if [ $# -lt 2 ]; then - echo "Too few Arguments" - usage - exit - fi - NEW_TYPE="$2"; - shift 2; - continue; - } - echo "Parameter $1 discarded" - shift 1; -done -} -get_config "$@" -if [[ "${file}" != "" ]]; then - img_convert "${file}" -fi -if [[ "${folder}" != "" ]]; then - folder_magic "${folder}" -fi diff --git a/rename.sh b/rename.sh deleted file mode 100755 index 0c61416..0000000 --- a/rename.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -if [ $# -lt 2 ]; then - echo "Missing Arguments rename ()" - exit 0 -fi -NewName=$2 -OldName=$1 -FileRegex=$3 -for file in $(ls | grep .*$FileRegex.*); do - mv $file "$(echo $file | sed 's/'"$OldName"'/'"$NewName"'/g')" -done - -# for file in $(ls | grep Big_.*_SuicideGirls); do echo $(echo $file | sed 's/Big_\(.*\)_Suicide/Big_SuicideGirls_\1/g'); done diff --git a/repair_boot.sh b/repair_boot.sh deleted file mode 100755 index b836ebf..0000000 --- a/repair_boot.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -DEV=$(sudo parted -l | grep "ATA ST1000LM014-1EJ1" -A1 | grep Disk | grep -o "sd[a-f]") -EFI=$(sudo parted -l | grep efi | cut -f2 -d' ') -UBUNTU=$(sudo parted -l | grep ext4 | cut -f2 -d' ') -echo "Ubuntu: ${UBUNTU}" -echo "EFI: ${EFI}" -echo "DEV: ${DEV}" -echo "Continue?" -read -n 1 -t 5 cont -if [ "${cont}" == "y" ]; then -sudo mount /dev/${DEV}${UBUNTU} /mnt -sudo mount /dev/${DEV}${EFI} /mnt/boot/efi - -sudo mount -o bind /dev /mnt/dev -sudo mount -o bind /sys /mnt/sys -sudo mount -t proc /proc /mnt/proc -sudo cp /proc/mounts /mnt/etc/mtab -sudo chroot /mnt /bin/bash -grub-install /dev/${DEV} -else - echo "Abort" - exit -fi diff --git a/reverseCommands.py b/reverseCommands.py deleted file mode 100755 index 0ba6756..0000000 --- a/reverseCommands.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python3 - -import os -import shutil -import sys - -def parse_line(line): - line = line.strip() - if not line or line.startswith("#"): - return None - - for sep in ["→", "->"]: - if sep in line: - src, dst = map(str.strip, line.split(sep, 1)) - return src, dst - - return None - - -def move_with_overwrite(src, dst): - if not os.path.exists(src) and not os.path.islink(src): - print(f"[SKIP missing source] {src}") - return - - # If destination exists, remove it (overwrite behavior) - if os.path.lexists(dst): - try: - if os.path.isdir(dst) and not os.path.islink(dst): - shutil.rmtree(dst) - else: - os.remove(dst) - except Exception as e: - print(f"[FAIL delete dst] {dst}: {e}") - return - - # Ensure parent directory exists - os.makedirs(os.path.dirname(dst), exist_ok=True) - - try: - shutil.move(src, dst) - print(f"[OK] {src} -> {dst}") - except Exception as e: - print(f"[FAIL move] {src} -> {dst}: {e}") - - -def process(file_path): - with open(file_path, "r") as f: - for line in f: - parsed = parse_line(line) - if not parsed: - continue - - dst, src = parsed - move_with_overwrite(src, dst) - - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: python rename_apply.py ") - sys.exit(1) - - process(sys.argv[1]) \ No newline at end of file diff --git a/rsync_SW.sh b/rsync_SW.sh deleted file mode 100755 index 6eee047..0000000 --- a/rsync_SW.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -rsync -rthvue "ssh -p 3032" --delete-delay lucas@serverhost:/home/www/owncloud/owncloud/data/lucas/files/SW/ /media/lucas/LucasFestplatte/SW/ diff --git a/smartctl_send_results.sh b/smartctl_send_results.sh deleted file mode 100755 index 1eecbac..0000000 --- a/smartctl_send_results.sh +++ /dev/null @@ -1,5 +0,0 @@ -[sambashare] - comment = HomeAssistant Backup - path = /backup/homeassistant - read only = no - browsable = yes diff --git a/updatesavailable.sh b/updatesavailable.sh deleted file mode 100755 index 9caf1a5..0000000 --- a/updatesavailable.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -> /etc/motd -sudo apt-get update > /dev/null 2>&1 -remove=$(sudo apt-get -s autoremove | grep upgraded, | awk '{ printf "%i",$6; }') -echo "$remove packages can be removed." >> /etc/motd - diff --git a/usr_cmd.sh b/usr_cmd.sh deleted file mode 100755 index f38586d..0000000 --- a/usr_cmd.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -OCDIR="/home/lucas/Documents/Dokumente/Dokumente/Projekte/Server/scripts/" -if [ "$(hostname)" == "raspberry" ];then - DIR="/home/lucas/Raspberry/scripts/" -elif [ "$(hostname)" == "serverhost" ] || [ "$(hostname)" == "workhost" ];then - DIR="/home/lucas/scripts/" -else - printf "Wrong Host! WTF?\n" -fi -scriptname=("hoststatus.sh" "wol.sh" "MSgrep.sh" "shutdown.sh" "deluge-client.sh") -cmdname=("hoststatus" "wake" "MSgrep" "hostdown" "dinfo") -len=${#scriptname[@]} -for (( i=0; i<${#scriptname[@]}; i++ )); do - if [ ! -f "/usr/local/bin/${cmdname[$i]}" ] && [ -f "${DIR}${scriptname[$i]}" ];then - printf "%s%s %s\n" "${DIR}" "${scriptname[$i]}" "${cmdname[$i]}" - ln -s ${DIR}${scriptname[$i]} /usr/local/bin/${cmdname[$i]} - fi - if [ ! -f "/usr/local/bin/${cmdname[$i]}" ] && [ -f "${OCDIR}${scriptname[$i]}" ];then - printf "%s%s %s\n" "${OCDIR}" "${scriptname[$i]}" "${cmdname[$i]}" - ln -s ${OCDIR}${scriptname[$i]} /usr/local/bin/${cmdname[$i]} - fi -done diff --git a/wallpaperChangerDeprecated.sh b/wallpaperChangerDeprecated.sh deleted file mode 100755 index 7c58c3c..0000000 --- a/wallpaperChangerDeprecated.sh +++ /dev/null @@ -1,827 +0,0 @@ -#!/bin/bash -## For laptop lid trigger: Write following in /etc/acpi/events/lm_lid -# event=button/lid.* -# action=/data/DatenLucas/Dokumente/Dokumente/Projekte/Server/scripts/quiethost/wallpaperChanger.sh -l -c -LOG_DIR="/home/lucas/.LOG/" -IMG_DIR="/data/DatenLucas/Media/Stuff/Wallpaper/" -PrivKey="file:/home/lucas/Documents/Dokumente/Projekte/Server/quiethost/IMG_privateKey.pem" -MONITOR_FILE="/home/lucas/.config/monitors.xml" -THALES=false -IMG_FOLDER="Desktop1920x1080/" -X_FOLDER="corrupt" -DAEMON=false -LOG=false -DECODE_SINGLE=false -REMOVE=false -CUSTOM_DIR=false -CONFIG=false -CONFIGFILE="wp.conf" -DEVICE_CARD="card0" -NAMING_TABLE="naming_table.txt" -NAMING_TABLE_ENC="naming_table_enc.txt" -EXCLUDE_CONFIG_DEF="XXXDEFAULTXXX" -REPLACE_ENC_IMG=false -WC_USER="lucas" -WC_GROUP="lucas" -EDIT_CONFIG=false -usage(){ - printf "Usage: - -u\t\t\tUDEV Mode - -a\t\t\tacapid Mode(Lid Close DAEMON) - -t \t\tStart DAEMON and Change Image every min Interval - -p \t\tPath of Image folder - -s \t\tChose Search Parameters(everything until next -*) - -ex \t\tExclude String from Search - -c\t\t\tUse Config File - -l\t\t\tUse Log File - -elements\tInclude Spectral Lines of Elements Pictures - -thales\t\t\tUse thales Config - -e\t\t\tEdit Config File - -h\t\t\tDisplay this\n" -} -usageX(){ - printf "UsageX: - -x\t\t\tSwitch Source Folder to X - -X\t\t\tClear Config and change Wallpaper - -dec_all\t\tDecode all Images - -dec_leave\t\tLeave used Images decoded - -dec_arg \tDecode certain Images matching pattern ** - -printNT\t\tDecode NT to stdout - -modifyNT\t\tDecode NT/Encode if decoded NT present - -replace\t\tReplace Image in NT - -insta\t\tInsta Mode\n" -} -change_image(){ - SZ="1920x1080" - IMGtype=("Wallpaper" "Screensaver" "Grub" "Login") - valueGnomeOpt=("'stretched'" "'spanned'") - typeGnomeOpt=("background" "screensaver") - MONITOR_num=$((${#screen_width_X[@]} - 1)) - EXCLUDE=${EXCLUDE_CONFIG} - for IMG in $(find ${IMG_DIR}${IMG_FOLDER} -name '*.jp*g' -or -name '*.JP*G'); do - if [ "$(identify $IMG | grep -iP "jp[e]?g")" != "" ]; then - convert "$IMG" "$(echo $IMG | sed 's/JP[E]\?G/png/g' | sed 's/jp[e]\?g/png/g')" - rm "$IMG" - IMG="$(echo $IMG | sed 's/JP[E]\?G/png/g' | sed 's/jp[e]\?g/png/g')" - fi - done - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ] && [ "${DAEMON}" == "false" ];then - echo "Check Encryprion" - check_encryption - fi - IMG_NUM_TOTAL=$(find ${IMG_DIR}${IMG_FOLDER} -name '*.png' | wc -l) - for (( i=0;i<${#IMGtype[@]};i++ )); do # i = Background/Screensaver/Grub - echo "Change ${IMGtype[${i}]}" - if [ ${i} -ge 2 ]; then - EXCLUDE="Panorama" - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ];then - echo Search - SEARCH="" - IMG_FOLDER="Desktop1920x1080/" - fi - if [[ ${i} -eq 3 ]] && [[ ${THALES} == "false" ]]; then - SEARCH="" - SEARCH[0]="Elements" - EXCLUDE=${EXCLUDE_CONFIG_DEF} - fi - for (( k=0;k<${#SEARCH[@]};k++ )); do - SEARCH[$k]="$(echo "${SEARCH[$k]}" | sed 's/Panorama//g')" - done - fi - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ];then - echo "Decode Naming Table" - file_path="${IMG_DIR}${IMG_FOLDER}/" - if [ -f "${file_path}${NAMING_TABLE_ENC}" ];then - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE_ENC}" -out "${file_path}${NAMING_TABLE}" -pass "${PrivKey}" - fi - fi - ConvertSTR="" - for (( j=0;j<${MONITOR_num};j++ )); do # j = Screen - ind=$((${i}*2+$j)) - img_fit_counter=0; - IMG_FIT=false - while ! $IMG_FIT; do - if [ ${#SEARCH[@]} -eq 1 ]; then - SEARCH_PARAMETER=${SEARCH[0]} - else - SEARCH_PARAMETER=${SEARCH[$ind]} - fi - SEARCH_NUM="$(echo ${SEARCH_PARAMETER} | grep -oE "[[:digit:]]{2}")" - SEARCH_STR="$(echo ${SEARCH_PARAMETER} | grep -oE "[^[:digit:]]+")" - echo "Search Parameter: ${SEARCH_STR} - ${SEARCH_NUM}, exclude ${EXCLUDE}" - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ];then - IMG_count=$(cat "${file_path}${NAMING_TABLE}" | cut -f1 -d';' | grep -i "${SEARCH_STR}.*${SEARCH_NUM}" | grep -iv "${EXCLUDE}" | grep -v "_decrypted" | wc -l) - else - IMG_count=$(find ${IMG_DIR}${IMG_FOLDER} -name '*.png' | grep -i "${SEARCH_STR}.*${SEARCH_NUM}" | grep -iv "${EXCLUDE}" | grep -v "_decrypted" | wc -l) - fi - if [ ${IMG_count} -eq 0 ];then - echo "No image found for ${IMGtype[${i}]} ${SEARCH_STR}" - if [ "${SEARCH_STR}" == "" ];then - exit 1 - else - SEARCH="" - continue - fi - else - echo "${IMG_count} Images found" - fi - NUM=$(($RANDOM % $IMG_count)) - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ];then - IFS=$'\n'; set -f - IMG_ARR=($(cat "${file_path}${NAMING_TABLE}" | cut -f1 -d';' | grep -i "${SEARCH_STR}.*${SEARCH_NUM}" | grep -iv "${EXCLUDE}")) - IMG_ENC_ARR=($(cat "${file_path}${NAMING_TABLE}" | grep "$(echo ${IMG_ARR[@]} | sed 's/ /\\\|/g')" | cut -f2 -d';')) - unset IFS; set +f - else - IFS=$'\n'; set -f - IMG_ARR=($(find ${IMG_DIR}${IMG_FOLDER} -name '*.png' | grep -i "${SEARCH_STR}.*${SEARCH_NUM}" | grep -iv "${EXCLUDE}" | grep -v "_decrypted")) - unset IFS; set +f - fi - IMG=${IMG_ARR[$NUM]} - for (( k=0;k<${#IMAGES[@]};k++ ));do - if [[ ("${SEARCH[0]}" != "${SEARCH_PARAMETER}" && "${SEARCH_NUM}" != "" ) || ("${SEARCH[0]}" == "${SEARCH_PARAMETER}" && "${SEARCH_NUM}" == "") ]]; then - counter=0; - while [[ "${IMG}" == ${IMAGES[$k]} && ${counter} -lt ${IMG_count} ]]; do - echo Disable Same Image - NUM=$(($RANDOM % $IMG_count)) - IMG=${IMG_ARR[$NUM]} - ((counter++)) - done - fi - done - IMAGES[$ind]=$IMG - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ];then - echo "Decrypt Image" - IMG_DEC=${file_path}${IMG} - IMG_ENC=${IMG_ENC_ARR[$NUM]} - if [ -f "${file_path}${IMG_DEC}" ]; then - echo "File Name already present: ${IMG_DEC}" - IMG_DEC="$(echo "${IMG_DEC}" | sed 's/.png/_DOUBLE_'"${RANDOM}"'\.png/g')" - fi - openssl enc -aes-256-cbc -pbkdf2 -d -in "${file_path}${IMG_ENC}" -out "${IMG_DEC}" -pass "${PrivKey}" - if [ $? -eq 0 ]; then - echo "Decryption Succesfull" - else - echo "Decryption failed" - fi - IMG=${IMG_DEC} - fi - if [[ "$(echo ${IMG} | grep "Elements/Elements_")" != "" ]]; then - for ((k=0;k<3;k++)); do - if [ ${i} -lt 3 ]; then - POINTSIZE=12 - else - POINTSIZE=24 - fi - IFS=$'\n'; set -f - IMG_ARR2=($(find ${IMG_DIR}${IMG_FOLDER} -name '*.png' | grep "Elements/Elements_" | grep -v "${IMG}")) - unset IFS; set +f - IMG_count2=${#IMG_ARR2[@]} - NUM=$(($RANDOM % $IMG_count2)) - IMG2=${IMG_ARR2[$NUM]} - convert -append $IMG $IMG2 "${LOG_DIR}NextCombined.png" - NUM=$(echo $IMG | grep -o -P '(?<=Panorama_).*(?=.png)' | cut -f1 -d'_') - NUM2=$(echo $IMG2 | grep -o -P '(?<=Panorama_).*(?=.png)' | cut -f1 -d'_') - LET=$(echo $IMG | grep -o -P '(?<=Panorama_).*(?=.png)' | cut -f2 -d'_') - LET2=$(echo $IMG2 | grep -o -P '(?<=Panorama_).*(?=.png)' | cut -f2 -d'_') - NAME=$(echo $IMG | grep -o -P '(?<=Panorama_).*(?=.png)' | cut -f3 -d'_') - NAME2=$(echo $IMG2 | grep -o -P '(?<=Panorama_).*(?=.png)' | cut -f3 -d'_') - NAME="$(printf "%s %s %s" "$NUM" "$LET" "$NAME")" - if [ "$( echo ${NAME} | grep -o "[A-Za-z]")" == "" ]; then NAME=${NAME_BUF}; fi - NAME2="$(printf "%s %s %s" "$NUM2" "$LET2" "$NAME2")" - if [ $(( ${k}%2 )) -eq 0 ]; then - y_1=$(( 510 + k*540 )); - y_2=$(( 580 + k*540 )); - convert -font helvetica -fill white -pointsize ${POINTSIZE} -draw "text 20,'${y_1}' '${NAME}' text 20,'${y_2}' '${NAME2}'" "${LOG_DIR}NextCombined.png" "${LOG_DIR}NextCombined.png" - fi - IMG="${LOG_DIR}NextCombined.png" - NAME_BUF=${NAME2} - if [ ${i} -lt 3 ]; then break; fi - done - fi - ## Aspect Ratio Part - imageAR=$(getAspectRatio ${IMG}) - printf "%s%d: $(echo ${IMG} | rev | cut -f1 -d'/' | rev) IAR: %s - SAR: %s\n" "${IMGtype[${i}]}" "${j}" "${imageAR}" "${screen_Aspect_Ratio[$j]}" - if [[ "$IMG" == "" ]]; then exit; fi - BIGIMG=false - AR_tolerance="0.26" - if [ $(echo ${imageAR}'=='${screenAR_ARR[${i}]} | bc -l) -eq 1 ]; then - # if [ ${MONITOR_num} -eq 1 ]; then break; fi - echo "Copy $((${screen_width_X[$j]}*${MONITOR_num}))x${screen_height_Y[$j]} Image" - cp "$IMG" "${LOG_DIR}Next${IMGtype[${i}]}.png" - IMG_FIT=true - BIGIMG=true - j=${MONITOR_num} - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ] && ! ${DECODE_SINGLE} ;then - echo "Remove Decrypted Image" - rm ${IMG} - fi - break - elif [[ $(echo ${imageAR}'<'${screenAR_ARR[${i}]}'*(1+'${AR_tolerance}')' | bc -l) -eq 1 && $(echo ${imageAR}'>'${screenAR_ARR[${i}]}'*(1-'${AR_tolerance}')' | bc -l) -eq 1 ]] ;then - # if [ ${MONITOR_num} -eq 1 ]; then break; fi - echo "Convert Image to $((${screen_width_X[$j]}*${MONITOR_num}))x${screen_height_Y[$j]}" - convert "$IMG" -resize $((${screen_width_X[$j]}*${MONITOR_num}))x${screen_height_Y[$j]}\! "${LOG_DIR}Next${IMGtype[${i}]}.png" - IMG_FIT=true - BIGIMG=true - j=${MONITOR_num} - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ] && ! ${DECODE_SINGLE} ;then - echo "Remove Decrypted Image" - rm "${IMG}" - fi - break - elif [ $(echo ${imageAR}'=='${screen_Aspect_Ratio[$j]} | bc -l) -eq 1 ]; then - img_height_X="$(identify $IMG | cut -f3 -d' ' | cut -f2 -d'x')" - img_width_Y="$(identify $IMG | cut -f3 -d' ' | cut -f1 -d'x')" - #echo "${img_width_Y}x${img_height_X}:${screen_width_X[$j]}x${screen_height_Y[$j]}" - if [[ "${img_width_Y}" != "${screen_width_X[$j]}" || "${img_height_X}" != "${screen_height_Y[$j]}" ]]; then - echo "Convert Image to ${screen_width_X[$j]}x${screen_height_Y[$j]} Image" - IMG_FIT=true - convert "$IMG" -resize ${screen_width_X[$j]}x${screen_height_Y[$j]}\! "${LOG_DIR}IMG$ind.png" - ConvertSTR="$ConvertSTR ${LOG_DIR}IMG$ind.png" - else - echo "Copy ${screen_width_X[$j]}x${screen_height_Y[$j]} Image" - IMG_FIT=true - cp "$IMG" "${LOG_DIR}IMG$ind.png" - ConvertSTR="$ConvertSTR ${LOG_DIR}IMG$ind.png" - fi - elif [[ $(echo ${imageAR}'<'${screen_Aspect_Ratio[$j]}'*(1+'${AR_tolerance}')' | bc -l) -eq 1 && $(echo ${imageAR}'>'${screen_Aspect_Ratio[$j]}'*(1-'${AR_tolerance}')' | bc -l) -eq 1 ]]; then - echo "Convert Image to ${screen_width_X[$j]}x${screen_height_Y[$j]}" - convert "$IMG" -resize ${screen_width_X[$j]}x${screen_height_Y[$j]}\! "${LOG_DIR}IMG$ind.png" - cp "$IMG" "$( echo "${IMG}_bak" | sed 's/_decrypted//g')" - IMG_FIT=true - cp "${LOG_DIR}IMG$ind.png" "$IMG" - ConvertSTR="$ConvertSTR ${LOG_DIR}IMG$ind.png" - else - echo "Image ${IMG} out of bounds" - fi - ((img_fit_counter++)) - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ] && ! ${DECODE_SINGLE} ;then - echo "Remove Decrypted Image" - rm "${IMG}" - fi - if [ $img_fit_counter -ge $IMG_NUM_TOTAL ]; then - echo "No Images Found. Change Search Parameter" - break - fi - done - done - if ! $BIGIMG; then - convert $ConvertSTR -background black +append ${LOG_DIR}Next${IMGtype[${i}]}.png - fi - mv ${LOG_DIR}Next${IMGtype[${i}]}.png ${LOG_DIR}Current${IMGtype[${i}]}.png - chmod 777 ${LOG_DIR}Current${IMGtype[${i}]}.png - if [[ "$(whoami)" == "root" && ${i} -lt 2 ]]; then - if [ "$(su ${WC_USER} -c "gsettings get org.gnome.desktop.${typeGnomeOpt[${i}]} picture-uri")" != "'file://${LOG_DIR}Current${IMGtype[${i}]}.png'" ]; then - echo Set gsettings ${type[${i}]} picture-uri - su ${WC_USER} -c "gsettings set org.gnome.desktop.${typeGnomeOpt[${i}]} picture-uri file://${LOG_DIR}Current${IMGtype[${i}]}.png" - fi - if [ "$(su ${WC_USER} -c "gsettings get org.gnome.desktop.${typeGnomeOpt[${i}]} picture-options")" != "'spanned'" ]; then - echo Set gsettings ${typeGnomeOpt[${i}]} picture-options - su ${WC_USER} -c "gsettings set org.gnome.desktop.${typeGnomeOpt[${i}]} picture-options spanned" - fi - chown ${WC_USER}:${WC_GROUP} ${LOG_DIR}*png - elif [ ${i} -lt 2 ]; then - if [ "$(gsettings get org.gnome.desktop.${typeGnomeOpt[${i}]} picture-uri)" != "'file://${LOG_DIR}Current${IMGtype[${i}]}.png'" ]; then - echo Set gsettings ${type[${i}]} picture-uri - gsettings set org.gnome.desktop.${typeGnomeOpt[${i}]} picture-uri file://${LOG_DIR}Current${IMGtype[${i}]}.png - fi - if [ "$(gsettings get org.gnome.desktop.${typeGnomeOpt[${i}]} picture-options)" != "'spanned'" ]; then - echo Set gsettings ${typeGnomeOpt[${i}]} picture-options - gsettings set org.gnome.desktop.${typeGnomeOpt[${i}]} picture-options spanned - fi - fi - if [ "${IMG_FOLDER}" == "${X_FOLDER}" ] ;then - echo "Remove Naming Table" - rm "${file_path}${NAMING_TABLE}" - fi - done -} -getAspectRatio() { - if [ "$1" == "" ]; then return "0"; fi - identify "$1" | perl -ne '/(.+?)\s+[A-Z]{3}\s+(\d+)x(\d+)/; print $3/$2, "\n"' -} -decode_all() { - echo "Decode all Images" - IMG_FOLDER_TMP="${X_FOLDER}" - file_path="${IMG_DIR}${IMG_FOLDER_TMP}/" - if [ -f "${file_path}${NAMING_TABLE_ENC}" ];then - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE_ENC}" -out "${file_path}${NAMING_TABLE}" -pass "${PrivKey}" - fi - for file in $(find ${IMG_DIR}${IMG_FOLDER_TMP} -name '*.png_enc'); do - if [ "$(identify ${file} 2>>/dev/null | grep "PNG")" == "" ]; then - DEC_NAME="${file_path}$(cat "${file_path}${NAMING_TABLE}" | grep "$(echo ${file} | rev | cut -f1 -d'/' | rev)" | cut -f1 -d';')" - if [ -f "${file_path}${DEC_NAME}" ]; then - echo "File Name already present: ${DEC_NAME}" - DEC_NAME="$(echo "${DEC_NAME}" | sed 's/.png/_DOUBLE_'"${RANDOM}"'\.png/g')" - else - echo "Decode ${DEC_NAME}" - fi - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file}" -out "${DEC_NAME}" -pass "${PrivKey}" - rm ${file} - fi - done - rm "${file_path}${NAMING_TABLE_ENC}" - rm "${file_path}${NAMING_TABLE}" -} -check_encryption() { - IMG_FOLDER="${X_FOLDER}" - ENC_FILE_COUNT=0; - file_path="${IMG_DIR}${IMG_FOLDER}/" - for file in $(find ${IMG_DIR}${IMG_FOLDER} -name '*.png_enc'); do - ENC_FILE_ARR[${ENC_FILE_COUNT}]=${file} - ((ENC_FILE_COUNT++)) - done - ((ENC_FILE_COUNT--)) - IFS=$'\n' ENC_FILE_ARR=($(sort <<<"${ENC_FILE_ARR[*]}")) - unset IFS - if [ -f "${file_path}${NAMING_TABLE_ENC}" ];then - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE_ENC}" -out "${file_path}${NAMING_TABLE}" -pass "${PrivKey}" - fi - for file in $(find ${IMG_DIR}${IMG_FOLDER} -name '*.png' | sort); do - if [ "$(identify ${file} 2>>/dev/null | grep "PNG")" != "" ]; then - if [ ${#ENC_FILE_ARR[@]} -eq 0 ]; then - ENC_FILE_COUNT=0 - ENC_NAME_CORE="0" - cat "${file_path}${NAMING_TABLE}" - else - ENC_NAME_CORE=$(( $(echo "${ENC_FILE_ARR[${ENC_FILE_COUNT}]}" | cut -d'.' -f1 | rev | cut -f1 -d'/' | rev | bc) + 1)) - ((ENC_FILE_COUNT++)) - fi - ENC_NAME="$(printf "%05d" ${ENC_NAME_CORE}).png_enc" - ENC_FILE_ARR[${ENC_FILE_COUNT}]=${ENC_NAME} - if [ -f "${file_path}${ENC_NAME}" ]; then - echo "File Name already present: ${ENC_NAME}" - ENC_NAME="$(echo "${ENC_NAME_CORE}")_DOUBLE_${RANDOM}.png_enc" - else - echo "Encode ${file} to ${ENC_NAME}" - fi - file_identifier="$( echo "${file}" | rev | cut -f1 -d'/' | rev)" - if [ -f "${file_path}${NAMING_TABLE}" ];then - if [ "$(cat "${file_path}${NAMING_TABLE}" | grep "${file_identifier}")" != "" ] && ! ${REPLACE_ENC_IMG} ; then - echo "Identifier ${file_identifier} already present, changing to" - file_identifier="$(echo "${file_identifier}" | sed 's/\.png/_enc_DOUBLE_'"${RANDOM}"'\.png/g')" - echo "${file_identifier}" - echo "${file_identifier};${ENC_NAME}" >> "${file_path}${NAMING_TABLE}" - elif [ "$(cat "${file_path}${NAMING_TABLE}" | grep "${file_identifier}")" != "" ] && ${REPLACE_ENC_IMG} ; then - ENC_NAME="$(cat "${file_path}${NAMING_TABLE}" | grep "${file_identifier}" | cut -d';' -f2)" - echo "Identifier ${file_identifier} already present, replacing image ${ENC_NAME}" - else - echo "${file_identifier};${ENC_NAME}" >> "${file_path}${NAMING_TABLE}" - fi - fi - openssl enc -aes-256-cbc -pbkdf2 -salt -in "${file}" -out "${file_path}${ENC_NAME}" -pass "${PrivKey}" - rm "${file}" - fi - done - openssl enc -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE}" -out "${file_path}${NAMING_TABLE_ENC}" -pass "${PrivKey}" - rm "${file_path}${NAMING_TABLE}" - IMG_FOLDER="${X_FOLDER}" -} -decode_images() { - echo "Decode All *$1*" - IMG_FOLDER_TMP="${X_FOLDER}" - file_path="${IMG_DIR}${IMG_FOLDER_TMP}/" - if [ -f "${file_path}${NAMING_TABLE_ENC}" ];then - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE_ENC}" -out "${file_path}${NAMING_TABLE}" -pass "${PrivKey}" - fi - files=($(cat "${file_path}${NAMING_TABLE}" | grep -e ".*$1.*" | cut -f2 -d';')) - for file in ${files[@]}; do - if [ "$(identify ${file} 2>>/dev/null | grep "PNG")" == "" ]; then - naming_table_line=$(cat "${file_path}${NAMING_TABLE}" | grep "$(echo ${file} | rev | cut -f1 -d'/' | rev)") - DEC_NAME="${file_path}$(echo ${naming_table_line} | cut -f1 -d';')" - if [ "$(echo ${naming_table_line} | grep -e ".*$1.*")" == "" ]; then - continue - fi - if [ -f "${DEC_NAME}" ]; then - echo "File Name already present: ${DEC_NAME}" - DEC_NAME="$(echo "${DEC_NAME}" | sed 's/.png/_DOUBLE_'"${RANDOM}"'\.png/g')" - else - echo "Decode ${DEC_NAME}" - fi - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${file}" -out "${DEC_NAME}" -pass "${PrivKey}" - if [[ "${REMOVE}" == "true" ]]; then - echo "Remove line ${naming_table_line} from Naming Table" - sed -i '/'"${naming_table_line}"'/d' ${file_path}${NAMING_TABLE} - echo "Remove ${file_path}${file}" - rm "${file_path}${file}" - fi - fi - done - openssl enc -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE}" -out "${file_path}${NAMING_TABLE_ENC}" -pass "${PrivKey}" - rm "${file_path}${NAMING_TABLE}" -} -printNamingTable() { - IMG_FOLDER_TMP="${X_FOLDER}/" - file_path="${IMG_DIR}${IMG_FOLDER_TMP}/" - if [ -f "${file_path}${NAMING_TABLE_ENC}" ];then - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE_ENC}" -pass "${PrivKey}" - else - echo "No Naming Table under ${file_path}${NAMING_TABLE_ENC}" - fi -} -modifyNT() { - IMG_FOLDER_TMP="${X_FOLDER}/" - file_path="${IMG_DIR}${IMG_FOLDER_TMP}" - NAMING_TABLE="naming_table_mod.txt" - if [ -f "${file_path}${NAMING_TABLE_ENC}" ];then - if [ ! -f "${file_path}${NAMING_TABLE}" ];then - openssl enc -d -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE_ENC}" -out "${file_path}${NAMING_TABLE}" -pass "${PrivKey}" - echo "Decrypting to ${file_path}${NAMING_TABLE}" - else - openssl enc -aes-256-cbc -pbkdf2 -salt -in "${file_path}${NAMING_TABLE}" -out "${file_path}${NAMING_TABLE_ENC}" -pass "${PrivKey}" - rm "${file_path}${NAMING_TABLE}" - echo "Encrypting to ${file_path}${NAMING_TABLE_ENC}" - fi - else - echo "No Naming Table under ${file_path}${NAMING_TABLE_ENC}" - fi -} -logfile_cleanup(){ - size=$(ls -l $LOG_FILE | cut -f5 -d' ') - echo Logfile Size: $size - if [ $size -gt 10000 ]; then - lines=$(wc -l $LOG_FILE | cut -f1 -d' ') - lines_new=$(($lines / 2)) - echo Lines: $lines - echo Lines_new: $lines_new - sed -i "1,${lines_new}d" $LOG_FILE - exec 1>>${LOG_FILE} 2>&1 - fi -} -sort_ARR(){ - for ((i=0; i <= $((${#screen_pos_X[@]} - 2)); ++i)); do - for ((j=((i + 1)); j <= ((${#screen_pos_X[@]} - 1)); ++j)); do - if [[ ${screen_pos_X[i]} -gt ${screen_pos_X[j]} ]]; then - tmp1=${screen_pos_X[i]} - screen_pos_X[i]=${screen_pos_X[j]} - screen_pos_X[j]=$tmp1 - tmp2=${screen_width_X[i]} - screen_width_X[i]=${screen_width_X[j]} - screen_width_X[j]=$tmp2 - tmp3=${screen_height_Y[i]} - screen_height_Y[i]=${screen_height_Y[j]} - screen_height_Y[j]=$tmp3 - fi - done - done - - screen_width_X[${#screen_width_X[@]}]=${screen_width_X[0]} - screen_height_Y[${#screen_height_Y[@]}]=${screen_height_Y[0]} - screen_Aspect_Ratio[${#screen_Aspect_Ratio[@]}]=${screen_Aspect_Ratio[0]} - screenAR_ARR=("${screenAR}" "${screenAR}" "${screen_Aspect_Ratio[0]}" "${screen_Aspect_Ratio[0]}") -} -sum_ARR(){ -arr=($@) -if [ ${#arr[@]} -eq 0 ]; then return 0; fi -IFS='+'; set -f -sum=$(echo "scale=1;${arr[*]}"|bc) -unset IFS; set +f -echo $sum -} -get_screensize(){ - if [ "$(ls /sys/class/drm/${DEVICE_CARD}/ | grep "${DEVICE_CARD}-")" == "" ]; then - printf "Wrong Device Card: %s -> " "${DEVICE_CARD}" - DEVICE_CARD="card1" - printf "New: %s\n" "${DEVICE_CARD}" - fi - IFS=$'\n'; set -f - devices=($(ls /sys/class/drm/${DEVICE_CARD}/ | grep "${DEVICE_CARD}-" | cut -f2- -d'-')) - unset IFS; set +f - CONN_COUNT=0 - for ((i=0;i<${#devices[@]};i++)); do - echo "Device: ${devices[${i}]}" - devices_name[${i}]=$(echo ${devices[${i}]}| grep -o "[[:alpha:]]*" | grep -m1 "[[:alpha:]]*") - devices_num[${i}]=$(echo ${devices[${i}]}|rev| grep -o "[[:digit:]]" | grep -m1 "[[:digit:]]") - status[${i}]=$(cat /sys/class/drm/${DEVICE_CARD}/${DEVICE_CARD}-"${devices[${i}]}"/status) - enabled[${i}]=$(cat /sys/class/drm/${DEVICE_CARD}/${DEVICE_CARD}-"${devices[${i}]}"/enabled) - if [ $(echo ${devices[${i}]} | grep "eDP" | wc -l) -ge 1 ]; then - if [ $(grep "wallpaperChanger.sh" /etc/acpi/events/lm_lid 2>/dev/null | wc -l) -eq 0 ]; then - echo "ERROR: No laptop lid trigger file: /etc/acpi/events/lm_lid" - fi - if [ $(grep "open" /proc/acpi/button/lid/LID0/state | wc -l) -eq 0 ]; then - status[${i}]="disconnected" - echo "Laptop Lid closed" - else - echo "Laptop Lid open" - fi - fi - if [ "${status[${i}]}" == "connected" ] && [ "${enabled[${i}]}" == "enabled" ]; then - ((CONN_COUNT++)) - fi - echo "${devices[${i}]}: ${status[${i}]}, ${enabled[${i}]}" - done - if [ "${THALES}" == "true" ] && [ $(id -u) -eq 0 ];then - echo "Open Monitor File as lfaber" - CONFIG_ARR=($(sudo -u lfaber cat ${MONITOR_FILE} | tr '\n' ';' | sed 's/ \+//g' | sed 's/<\/configuration>/<\/configuration>\n/g' | grep "")) - else - echo "Open Monitor File" - CONFIG_ARR=($(cat ${MONITOR_FILE} | tr '\n' ';' | sed 's/ \+//g' | sed 's/<\/configuration>/<\/configuration>\n/g' | grep "")) - fi - for ((j=0;j<${#CONFIG_ARR[@]};j++)); do - CONFIG_ARR[$j]="$(echo "${CONFIG_ARR[$j]}" | tr ';' '\n')" - MONITOR_COUNT=$(echo "${CONFIG_ARR[$j]}" | grep -c "") - CONFIG_SUCCESS=true - if [ $CONN_COUNT -eq $MONITOR_COUNT ]; then - echo "Monitors: $MONITOR_COUNT" - for ((i=0;i<${#devices[@]};i++)); do - CONFIG_TEST=${CONFIG_ARR[$j]} - if [ "${status[${i}]}" == "connected" ]; then - SIZE_X="$(cat "/sys/class/drm/${DEVICE_CARD}/${DEVICE_CARD}-${devices[${i}]}/device/device/graphics/fb0/virtual_size" | cut -f1 -d',')" - SIZE_Y="$(cat "/sys/class/drm/${DEVICE_CARD}/${DEVICE_CARD}-${devices[${i}]}/device/device/graphics/fb0/virtual_size" | cut -f2 -d',')" - CONFIG_TEST="$(echo "${CONFIG_TEST}" | tr '\n' ';' | sed 's/<\/logicalmonitor>;/<\/logicalmonitor>\n/g' | grep "${devices_name[${i}]}" | grep "${devices_num[${i}]}" | grep ";${SIZE_X};${SIZE_Y};")" - fi - if [ "${CONFIG_TEST}" == "" ]; then - CONFIG_SUCCESS=false - echo "Wrong Monitor" - fi - done - if ${CONFIG_SUCCESS}; then - CONFIG_NEW="${CONFIG_ARR[$j]}" - else - echo "Wrong Monitor" - fi - else - echo "Connected Monitors: $CONN_COUNT" - echo "Configured Monitors: $MONITOR_COUNT" - fi - # CONFIG_ARR[$j]="$(echo "${CONFIG_ARR[$j]}" | grep "${devices[${i}]}")" - done - if [ $CONN_COUNT -eq 1 ]; then - for ((i=0;i<${#devices[@]};i++)); do - if [ "${status[${i}]}" == "connected" ]; then - SIZE_X="$(cat "/sys/class/drm/${DEVICE_CARD}/${DEVICE_CARD}-${devices[${i}]}/device/device/graphics/fb0/virtual_size" | cut -f1 -d',')" - SIZE_Y="$(cat "/sys/class/drm/${DEVICE_CARD}/${DEVICE_CARD}-${devices[${i}]}/device/device/graphics/fb0/virtual_size" | cut -f2 -d',')" - POS="0" - CONFIG_NEW="$SIZE_X\n$SIZE_Y\n$POS\n" - fi - done - fi - if [ "$CONFIG_NEW" == "" ]; then - echo "Abort: Monitor Information not consistent" - exit - fi - IFS=$'\n'; set -f - screen_width_X=($(echo -e "$CONFIG_NEW" | grep "width" | grep -o "[[:digit:]]*")) - screen_height_Y=($(echo -e "$CONFIG_NEW" | grep "height" | grep -o "[[:digit:]]*")) - screen_pos_X=($(echo -e "$CONFIG_NEW" | grep "" | grep -o "[[:digit:]]*")) - unset IFS; set +f - for ((i=0; i<${#screen_width_X[@]} ; i++ )); do - screen_Aspect_Ratio[${i}]=$(perl -E "say ${screen_height_Y[${i}]}/${screen_width_X[${i}]}") - done - screenAR=$(perl -E "say ${screen_height_Y[0]}/$(sum_ARR ${screen_width_X[@]})") -} -get_config() { -while [[ ${1:0:1} == - ]]; do - echo "Param: $1" - [[ $1 == -u ]] && { - MODE="udev"; - shift 1; - continue; - }; - [[ $1 == -a ]] && { - MODE="acpid"; - shift 1; - continue; - }; - [[ $1 == -t ]] && { - if [ $# -lt 2 ]; then - usage - exit - fi - minutes=$2; - DAEMON=true; - MODE="daemon"; - LOG=true; - shift 2; - continue; - }; - [[ $1 == -p ]] && { - if [ $# -lt 2 ]; then - usage - exit - fi - CUSTOM_DIR=true; - IMG_DIR=$2; - shift 2; - continue; - }; - [[ $1 == -e ]] && { - EDIT_CONFIG=true; - shift 1; - continue; - }; - [[ $1 == -s ]] && { - if [ $# -lt 2 ]; then - SEARCH="" - else - - counter=0 - while (true); do - if [[ "$2" == "-"* || "$2" == "" ]]; then shift 1; break; fi - SEARCH[$counter]=$2 - ((counter++)) - shift 1 - done - fi - continue; - }; - [[ $1 == -c ]] && { - CONFIG=true; - shift 1; - continue; - }; - [[ $1 == -elements ]] && { - EXCLUDE_CONFIG=${EXCLUDE_CONFIG_DEF} - shift 1; - continue; - }; - [[ $1 == -l ]] && { - LOG=true; - shift 1; - continue; - }; - [[ $1 == -x ]] && { - X_FOLDER="corrupt" - IMG_FOLDER="${X_FOLDER}" - shift 1; - continue; - }; - [[ $1 == -h ]] && { - usage - shift 1; - exit 0; - }; - [[ $1 == -hX ]] && { - usageX - shift 1; - exit 0; - }; - [[ $1 == -ex ]] && { - EXCLUDE_CONFIG="$2" - shift 2; - }; - [[ $1 == -X ]] && { - > /home/lucas/.LOG/wp.conf - rm /home/lucas/.LOG/IMG[0-3].png - shift 1; - continue; - }; - [[ $1 == -dec_leave ]] && { - DECODE_SINGLE=true - shift 1; - continue; - }; - [[ $1 == -insta ]] && { - X_FOLDER="insta" - IMG_FOLDER="${X_FOLDER}" - shift 1; - continue; - }; - [[ $1 == -dec_arg ]] && { - arg=$2; - shift 2; - [[ $1 == -rm ]] && { - REMOVE=true - shift 1; - }; - decode_images "${arg}" - exit 0; - }; - [[ $1 == -rm ]] && { - shift 1; - REMOVE=true - }; - [[ $1 == -dec_all ]] && { - decode_all - exit - }; - [[ $1 == -printNT ]] && { - printNamingTable - shift 1; - exit 0; - }; - [[ $1 == -modifyNT ]] && { - modifyNT - shift 1; - exit 0; - } - [[ $1 == -replace ]] && { - REPLACE_ENC_IMG=true - shift 1; - continue; - } - [[ $1 == -thales ]] && { - THALES=true - shift 1; - continue; - } - echo "Parameter $1 discarded" - shift 1; -done -} -echo Start $0 $@ -SEARCH="" -MODE="user"; -#EXCLUDE_CONFIG=${EXCLUDE_CONFIG_DEF} -EXCLUDE_CONFIG="elements" -get_config "$@" -if ${THALES}; then - LOG_DIR="/home/diskspace/lfaber/Wallpaper/.LOG/" - IMG_DIR="/home/diskspace/lfaber/Wallpaper/" - MONITOR_FILE="/homes/lfaber/.config/monitors.xml" - WC_USER="lfaber" - WC_GROUP="elektra" - PrivKey="" - count=0 - ret=1 - while [ ${count} -lt 100 ]; do - sudo -u lfaber id 2>&1 1>>/dev/null - ret=$? -echo $ret - if [ ${ret} -ne 0 ]; then - echo "Wait for user lfaber" - else - break - fi - sleep 10 - done - if [ ${ret} -ne 0 ]; then - echo "User lfaber not present, exit." - exit - else - echo "User lfaber loaded" - fi -fi -if $EDIT_CONFIG; then - vim "${LOG_DIR}${CONFIGFILE}" -fi -if $CONFIG; then - IFS=$' '; set -f - get_config $(cat "${LOG_DIR}${CONFIGFILE}") - unset IFS; set +f -fi -if $LOG; then - LOG_FILE="${LOG_DIR}wallpaperchanger_${MODE}.log" - ls $LOG_DIR >> /dev/null 2>&1 - if [[ $? -ne 0 ]]; then - echo "Directory $LOG_DIR not present" - exit 1 - fi - exec 1>>${LOG_FILE} 2>&1 - date -fi -if $CUSTOM_DIR; then - if [ "$(echo "${IMG_DIR: -1}")" == "/" ]; then - IMG_FOLDER="$(echo ${IMG_DIR} | rev | cut -f2 -d'/' | rev)/" - IMG_DIR="$(echo ${IMG_DIR} | rev | cut -f3- -d'/' | rev)/" - else - IMG_FOLDER="$(echo ${IMG_DIR} | rev | cut -f1 -d'/' | rev)/" - IMG_DIR="$(echo ${IMG_DIR} | rev | cut -f2- -d'/' | rev)/" - fi - echo ${IMG_FOLDER} - echo ${IMG_DIR} -fi -ls ${IMG_DIR}${IMG_FOLDER} >> /dev/null 2>&1 -if [[ $? -ne 0 ]]; then - echo "Directory ${IMG_DIR}${IMG_FOLDER} not present" - exit 1 -fi -get_screensize -sort_ARR - -if [ "${screenAR}" == "0.5625" ]; then - EXCLUDE_CONFIG="Panorama" -fi -echo "Screen Width: ${screen_width_X[@]}" -echo "Screen Height: ${screen_height_Y[@]}" -echo "Screen Pos: ${screen_pos_X[@]}" -echo "Monitor Aspect Ratio: ${screen_Aspect_Ratio[@]} - Screen: ${screenAR}" -echo "Dir: ${IMG_DIR}${IMG_FOLDER}" -echo "User: $(whoami)" -if ${DAEMON}; then - if [ "`echo $minutes | egrep ^[[:digit:]]+$`" = "" ];then - echo "$minutes is not an Integer" - exit - else - echo "Interval: $minutes min" - fi - echo "Start DAEMON" - sleep_time=$(( $minutes * 60 )) - while [[ 1 -eq 1 ]]; do - if $CONFIG; then - IMG_FOLDER="Desktop1920x1080/" - IFS=$' '; set -f - get_config $(cat "${LOG_DIR}${CONFIGFILE}") - unset IFS; set +f - fi - get_screensize - sort_ARR - change_image - date - logfile_cleanup - echo "DAEMON Mode" - sleep $sleep_time - done -else - change_image -fi -exit 0