From ed779a4bc67e7506ba5521ac1d2308aaedeb89de Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sat, 1 Jul 2023 20:58:49 +0530 Subject: .scripts: Adding order and rsyncfon script --- .scripts/order | 17 +++++++++++++++++ .scripts/rsyncfon | 24 ++++++++++++++++++++++++ .scripts/togglecaps | 4 ++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 .scripts/order create mode 100755 .scripts/rsyncfon diff --git a/.scripts/order b/.scripts/order new file mode 100755 index 0000000..ecd8f25 --- /dev/null +++ b/.scripts/order @@ -0,0 +1,17 @@ +#!/bin/sh +## Simple shellscript to index all directories present in a main directory based on their creation time + +noofdirs=$(find . -mindepth 1 -maxdepth 1 -type d | wc -l) +lenofnod=$(echo -n "$noofdirs" | wc -m) ## Flag n to prevent newline count + +# d flag for reverse indexing i.e most recent file-directory is indexed 1. +if [[ "$1" = "-d" ]]; then + ls -d */ -vt | cut -d'/' -f1 | nl -w$lenofnod -s ". " -n rz | while read n f; + do mv -n "$f" "$n $f" ; + done +#else by default index oldest file-directory as 1. +else + ls -d */ -vtr | cut -d'/' -f1 | nl -w$lenofnod -s ". " -n rz | while read n f; + do mv -n "$f" "$n $f" ; + done +fi diff --git a/.scripts/rsyncfon b/.scripts/rsyncfon new file mode 100755 index 0000000..90c95e1 --- /dev/null +++ b/.scripts/rsyncfon @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "Welcome to rsyncfon a fon to pc and vice-versa file-syncing script using the rsync algorithm!" +echo -e "What would you like to do?\r\n1)sync from phone to pc 2)sync from pc to phone" +read option +case "$option" in + "1") + echo -e "Enter public IP on mobile device (starting with 192.): \r\n!Make sure the device and the desktop are connected to the same network!" + read IP + echo "Enter file/folder to be rsync'd (Leave empty if entire sdcard) (/sdcard/*)" + read file + echo "Enter desination path on PC \r\n!!!Make sure to check whether it had sufficient space or not!!!" + read dest + rsync --update --progress -e 'ssh -p 2222' -azv $IP:/sdcard/$file $dest;; + "2") + echo "Enter file/folder from pc to be rsync'd" + read file + echo "Enter public IP" + read IP + echo "Enter destination location( /sdcard/*)" + read dest +rsync --update --progress -e 'ssh -p 2222' -azv $file root@$IP:$dest +esac + diff --git a/.scripts/togglecaps b/.scripts/togglecaps index 09dd90c..b3c1b48 100755 --- a/.scripts/togglecaps +++ b/.scripts/togglecaps @@ -5,11 +5,11 @@ hyprland_cfg="$HOME/.config/hypr/hyprland.conf" line1=$(grep "kb_options" "$hyprland_cfg" | head -n 1) line2=$(grep "kb_options" "$hyprland_cfg" | tail -n 1) -if [ "${line1:0:1}" = "#" ]; then +if echo "$line1" | grep -qE "^\s*#"; then # If first line is commented, uncomment it and comment the second line sed -i 's/^#\s*kb_options=caps:escape/kb_options=caps:escape/' "$hyprland_cfg" sed -i 's/^kb_options=ctrl:nocaps/# kb_options=ctrl:nocaps/' "$hyprland_cfg" -elif [ "${line2:0:1}" = "#" ]; then +elif echo "$line1" | grep -qE "^\s*#"; then # If second line is commented, uncomment it and comment the first line sed -i 's/^#\s*kb_options=ctrl:nocaps/kb_options=ctrl:nocaps/' "$hyprland_cfg" sed -i 's/^kb_options=caps:escape/# kb_options=caps:escape/' "$hyprland_cfg" -- cgit v1.2.3