Skip to content

Commit

Permalink
mini update
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbletu committed Apr 2, 2021
1 parent f6ca6ca commit 1b77cc4
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 31 deletions.
33 changes: 13 additions & 20 deletions normal_user/scripts/.scripts/any-term-dropdown
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
#!/usr/bin/env sh
### _ _ _ _
### __ _ ___ | |_| |__ | | ___| |_ _ _
### / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
###| (_| | (_) | |_| |_) | | __/ |_| |_| |
### \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
### |___/
### https://www.youtube.com/user/gotbletu
### https://lbry.tv/@gotbletu
### https://twitter.com/gotbletu
### https://github.com/gotbletu
###
### Author : gotbletu
### Name : any-term-dropdown
### Version : 0.1
### Date : 2015-02-15
### Description : turn any terminal into a dropdown terminal
### Depends On : coreutils xdotool wmutils (https://github.com/wmutils/core | https://aur.archlinux.org/packages/wmutils-git/)
### Video Demo : https://www.youtube.com/watch?v=mVw2gD9iiOg
#!/usr/bin/env bash
# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
# https://www.youtube.com/user/gotbletu
# DESC: turn any terminal into a dropdown terminal
# DEMO: https://www.youtube.com/watch?v=mVw2gD9iiOg
# DEPEND: coreutils xdotool wmutils (https://github.com/wmutils/core | https://aur.archlinux.org/packages/wmutils-git/)
# CLOG: 2021-02-10 use comm to match window name and class, this avoids terminal windows with different names
# 2015-02-15 0.1

# get screen resolution width and height
ROOT=$(lsw -r)
Expand All @@ -27,14 +16,18 @@ height=$(wattr h "$ROOT")
# my_term=urxvt
# my_term=sakura
my_term="xterm"
# my_term="alacritty"
# my_term=terminator
# my_term=gnome-terminal

# option 2: auto detect terminal emulator (note: make sure to only open one)
# my_term="urxvt|xterm|uxterm|termite|sakura|lxterminal|terminator|mate-terminal|pantheon-terminal|konsole|gnome-terminal|xfce4-terminal"

# get terminal emulator pid ex: 44040485
pid=$(xdotool search --class "$my_term" | tail -n1)
# pid=$(xdotool search --class "$my_term" | tail -n1)

# get terminal emulator and matching name pid ex: 44040485
pid=$(comm -12 <(xdotool search --name "$my_term" | sort) <(xdotool search --class "$my_term" | sort))

# get windows id from pid ex: 0x2a00125%
wid=$(printf 0x%x "$pid")
Expand Down
186 changes: 176 additions & 10 deletions normal_user/scripts/.scripts/mountjutsu
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@
### Date : 20190626
### Description : menu interface to mount, unmount, eject, clone, exactcopy, format, LUKS encryption
### Depends On : bash sudo grep gawk coreutils udisks2 util-linux
### gptfdisk dosfstools ntfs-3g hfsprogs exfat-utils e2fsprogs
### gptfdisk dosfstools ntfs-3g hfsprogs exfatprogs e2fsprogs
### cryptsetup clonezilla partclone partimage vlc cdw f3 smartmontools
### dvdbackup libdvdread libdvdcss cdrdao cdrtools(or cdrkit)
### Video Demo : https://www.youtube.com/watch?v=jipILuNW5Ks

### 2021-01-16 : change to exfatprogs, exFAT 32KB or 64KB cluster

# Next improvements: 1) delete MBR on format https://www.cyberciti.biz/faq/linux-clearing-out-master-boot-record-dd-command/
# clear out leftover label and fstype
# $ sudo dd if=/dev/zero of=/dev/sdX bs=446 count=1

# 2) blinking text warning


#-------- Bash Color Code {{{
#------------------------------------------------------
# DESC: color code for bash compatible shell
Expand Down Expand Up @@ -267,6 +276,10 @@ format2usb-fat32-32kbcluster() {
return 1
fi
echo -e "${Red}>>>Delete any existing partition then create a new single partition ${Color_Off}"

# delete existing label
sudo dd if=/dev/zero of=/dev/"$DEVICE_NAME" bs=446 count=1

echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\nb\nw" | sudo fdisk /dev/"$DEVICE_NAME"
# delete partiton x8 using d\n\n
# d delete a partition
Expand Down Expand Up @@ -399,6 +412,112 @@ format2usb-exfat() {
rmdir -v /tmp/testmount
}

format2usb-exfat-32kbcluster() {
if [ $# -lt 2 ]; then
echo -e "format and create a partition that fills up the whole device"
echo -e "exFAT label max is 15 character and is all uppercase"
echo -e "\nUsage: $0 <label> <device>"
echo -e "Example: $0 MY_USB sdx"
return 1
fi
# exFat likes the labels to be in uppercase
DEVICE_LABEL=$(echo "$1" | tr '[:lower:]' '[:upper:]')
DEVICE_NAME="$2"
echo -e "${Yellow}>>>Checking if device is mounted ${Color_Off}"
MOUNT_STATUS=$(mount | grep /dev/"$DEVICE_NAME" | wc -l)
if [ "$MOUNT_STATUS" -ne 0 ]
then
lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep "$DEVICE_NAME"
echo -e "${Red}>>>/dev/$DEVICE_NAME is mounted. You have to unmount the device and all of its partitions then try again ${Color_Off}"
return 1
fi
echo -e "${Yellow}>>>Please double check the device you are about to FORMAT ${Color_Off}"
lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep --color -E "$2|$"
echo -ne "${Red}>>>WARNING: You are about to FORMAT a device at /dev/$DEVICE_NAME. Do you want to continue? [y/n] ${Color_Off}"
read REPLY
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo -e "${Green}>>>You chose to continue ${Color_Off}"
else
return 1
fi
echo -e "${Red}>>>Delete any existing partition then create a new single partition ${Color_Off}"
echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\n7\nw" | sudo fdisk /dev/"$DEVICE_NAME"
# delete partiton x8 using d\n\n
# d delete a partition
# default, partition
# o create a new empty DOS partition table
# n add a new partition
# p print the partition table
# 1 partition number 1
# default, start immediately after preceding partition
# default, extend partition to end of disk
# t change a partition type (L to list all types)
# 7 HPFS/NTFS/exFAT
# w write table to disk and exit
echo -e "${Red}>>>Formatting the device ${Color_Off}"
sudo mkfs.exfat -c 32K -n "$DEVICE_LABEL" /dev/"$DEVICE_NAME"1
echo -e "${Red}>>>Changing permission of the filesystem ${Color_Off}"
mkdir -p -v /tmp/testmount
sudo mount /dev/"$DEVICE_NAME"1 /tmp/testmount
sudo chmod -R 777 /tmp/testmount
sudo umount /tmp/testmount
rmdir -v /tmp/testmount
}

format2usb-exfat-64kbcluster() {
if [ $# -lt 2 ]; then
echo -e "format and create a partition that fills up the whole device"
echo -e "exFAT label max is 15 character and is all uppercase"
echo -e "\nUsage: $0 <label> <device>"
echo -e "Example: $0 MY_USB sdx"
return 1
fi
# exFat likes the labels to be in uppercase
DEVICE_LABEL=$(echo "$1" | tr '[:lower:]' '[:upper:]')
DEVICE_NAME="$2"
echo -e "${Yellow}>>>Checking if device is mounted ${Color_Off}"
MOUNT_STATUS=$(mount | grep /dev/"$DEVICE_NAME" | wc -l)
if [ "$MOUNT_STATUS" -ne 0 ]
then
lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep "$DEVICE_NAME"
echo -e "${Red}>>>/dev/$DEVICE_NAME is mounted. You have to unmount the device and all of its partitions then try again ${Color_Off}"
return 1
fi
echo -e "${Yellow}>>>Please double check the device you are about to FORMAT ${Color_Off}"
lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep --color -E "$2|$"
echo -ne "${Red}>>>WARNING: You are about to FORMAT a device at /dev/$DEVICE_NAME. Do you want to continue? [y/n] ${Color_Off}"
read REPLY
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo -e "${Green}>>>You chose to continue ${Color_Off}"
else
return 1
fi
echo -e "${Red}>>>Delete any existing partition then create a new single partition ${Color_Off}"
echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\n7\nw" | sudo fdisk /dev/"$DEVICE_NAME"
# delete partiton x8 using d\n\n
# d delete a partition
# default, partition
# o create a new empty DOS partition table
# n add a new partition
# p print the partition table
# 1 partition number 1
# default, start immediately after preceding partition
# default, extend partition to end of disk
# t change a partition type (L to list all types)
# 7 HPFS/NTFS/exFAT
# w write table to disk and exit
echo -e "${Red}>>>Formatting the device ${Color_Off}"
sudo mkfs.exfat -c 64K -n "$DEVICE_LABEL" /dev/"$DEVICE_NAME"1
echo -e "${Red}>>>Changing permission of the filesystem ${Color_Off}"
mkdir -p -v /tmp/testmount
sudo mount /dev/"$DEVICE_NAME"1 /tmp/testmount
sudo chmod -R 777 /tmp/testmount
sudo umount /tmp/testmount
rmdir -v /tmp/testmount
}

format2usb-fat16() {
if [ $# -lt 2 ]; then
echo -e "format and create a partition that fills up the whole device"
Expand Down Expand Up @@ -482,6 +601,10 @@ format2usb-fat32() {
return 1
fi
echo -e "${Red}>>>Delete any existing partition then create a new single partition ${Color_Off}"

# delete existing label
sudo dd if=/dev/zero of=/dev/"$DEVICE_NAME" bs=446 count=1

echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\nb\nw" | sudo fdisk /dev/"$DEVICE_NAME"
# delete partiton x8 using d\n\n
# d delete a partition
Expand Down Expand Up @@ -1326,6 +1449,7 @@ main_list() {
MENU_FORMATDEVICE="
,${Green}m2|m3|m4|mx|mn|mh${Color_Off}, FORMAT MBR:, ext2 <=> ext3 <=> ext4 <=> exfat <=> ntfs <=> hfs+
,${Green}mt|mf|c3|c6${Color_Off}, FORMAT MBR:, fat16 <=> fat32 <=> fat32-32KB <=> fat32-64KB
,${Green}x3|x6${Color_Off}, FORMAT MBR:, exfat-32KB <=> exfat-64KB
,${Green}g2|g3|g4|gx|gn${Color_Off}, FORMAT GPT:, ext2 <=> ext3 <=> ext4 <=> exfat <=> ntfs
,${Green}l2|l3|l4${Color_Off}, FORMAT LUKS:, ext2 <=> ext3 <=> ext4
,${Green}cd|rd|cp|rp${Color_Off}, CLONING:, clone drive <=> restore drive <=> clone part <=> restore part
Expand All @@ -1345,14 +1469,15 @@ HELP="
${Green}mountjutsu${Color_Off}: simple menu to mount, unmount, format, eject, restore, clone drives and many other features.
dependencies: bash sudo grep gawk coreutils udisks2 util-linux
gptfdisk dosfstools ntfs-3g hfsprogs exfat-utils e2fsprogs
gptfdisk dosfstools ntfs-3g hfsprogs exfatprogs e2fsprogs
cryptsetup clonezilla partclone partimage vlc cdw f3 smartmontools
dvdbackup libdvdread libdvdcss cdrdao cdrtools(or cdrkit)
FORMAT MBR: format drive ${Red}[util-linux dosfstools exfat-utils e2fsprogs ntfs-3g hfsprogs]${Color_Off}
- FAT32 32KB Cluster (Wii, Gamecube, 3DS ...etc)
FORMAT MBR: format drive ${Red}[util-linux dosfstools exfatprogs e2fsprogs ntfs-3g hfsprogs]${Color_Off}
- FAT32 32KB Cluster (Wii, Gamecube, 3DS/DS/DSi/R4Card ...etc)
- exFAT 64KB Cluster (PSVita/PSTV)
- HFS+ (Mac OSX non-journal HFS+. Linux can write in HFS+ non-journaling mode only)
FORMAT GPT: format drive GREATER THAN 2TB ${Red}[gptfdisk exfat-utils e2fsprogs ntfs-3g]${Color_Off}
FORMAT GPT: format drive GREATER THAN 2TB ${Red}[gptfdisk exfatprogs e2fsprogs ntfs-3g]${Color_Off}
FORMAT LUKS: setup encryption and password, formats to different file systems ${Red}[cryptsetup e2fsprogs]${Color_Off}
CLONING: clone/restore drive or partition image ${Red}[clonezilla partclone partimage ntfs-3g coreutils]${Color_Off}
EXACT COPY DVDMovie: backup dvdmovie to ISO and bypass disc protection ${Red}[dvdbackup libdvdread libdvdcss]${Color_Off}
Expand All @@ -1362,7 +1487,7 @@ HELP="
BURNING: CD/DVD/ISO Ncurses Burning Tool ${Red}[cdw]${Color_Off}
HDD HEALTH: display info, enable or disable S.M.A.R.T ${Red}[smartmontools]${Color_Off}
HDD TEST: run a S.M.A.R.T test to check for Hard Drive Failures ${Red}[smartmontools]${Color_Off}
HDD STATS: show progress of S.M.A.R.T test. keep Hard Drive alive from entering sleep mode${Red}[smartmontools]${Color_Off}
HDD STATS: show progress of S.M.A.R.T test. keep Hard Drive alive from entering sleep mode ${Red}[smartmontools]${Color_Off}
MOUNTING: mount, unmount devices ${Red}[udisks2]${Color_Off}
EJECTING: unmount and eject devices, toggle disc tray ${Red}[udisks2 util-linux]${Color_Off}
PLAYBACK: play dvdmovie or audiocd (using cvlc and nvlc) ${Red}[vlc]${Color_Off}
Expand All @@ -1378,13 +1503,26 @@ list-all-drive() {
list-removable-drive() {
lsblk -o "hotplug,kname,tran,size,fstype,type,label,mountpoint,uuid,model" | head -n1
lsblk -o "hotplug,kname,tran,size,fstype,type,label,mountpoint,uuid,model" | awk '$1 == 1 || /rom/ || /usb/ || /crypt/ || /crypto_LUKS/ {print $0}'
printf '%s\n'
}
list-mtp-device() {
if [[ "$(simple-mtpfs -l 2>/dev/null | wc -l)" -gt 0 ]]; then
printf '%s\n' "MTP Devices [ Android > USB_Debugging=Enable,USB_Configuration=MTP ]"
simple-mtpfs -l
fi
if [[ "$(ls /run/user/$UID/mtp 2>/dev/null | wc -l)" -gt 0 ]]; then
printf '%s\n'
printf '%s\n' "MTP Mounted @ /run/user/$UID/mtp/"
ls -1 /run/user/$UID/mtp
fi
}

while true; do
clear
pidof tmux >/dev/null && tmux clear-history
printf '%s\n\n' '======================= LISTING REMOVABLE DEVICES ====================='
list-removable-drive
list-mtp-device
# printf '%s\n\n' '======================= LISTING ALL DEVICES ==========================='
# list-all-drive
printf '%s\n'
Expand Down Expand Up @@ -1504,6 +1642,22 @@ while true; do
format2usb-fat32-32kbcluster "$LABELNAME" "$DEVICE"
read -rsp $'Press any key to return to main menu\n' -n1 key
;;
x6)
echo -n "Which device do you want to format to exFAT 64KB Cluster MBR? (e.g sdx): "
read DEVICE
echo -n "What label name do you want to assign to $DEVICE ? (11 char): "
read LABELNAME
format2usb-exfat-64kbcluster "$LABELNAME" "$DEVICE"
read -rsp $'Press any key to return to main menu\n' -n1 key
;;
x3)
echo -n "Which device do you want to format to exFAT 32KB Cluster MBR? (e.g sdx): "
read DEVICE
echo -n "What label name do you want to assign to $DEVICE ? (11 char): "
read LABELNAME
format2usb-exfat-32kbcluster "$LABELNAME" "$DEVICE"
read -rsp $'Press any key to return to main menu\n' -n1 key
;;
mt)
echo -n "Which device do you want to format to FAT16 MBR? (e.g sdx): "
read DEVICE
Expand Down Expand Up @@ -1683,17 +1837,29 @@ while true; do
m)
echo -n "Which device do you want to mount? (e.g sdx1): "
read DEVICE
udisksctl mount --block-device "/dev/$DEVICE"
if [ $? -ne 0 ]; then
if [[ "$DEVICE" =~ ^[[:digit:]] ]]; then
# e.g) 1: SamsungGalaxy --> 1-SamsungGalaxy
mtp_num_name=$(simple-mtpfs -l | grep "^${DEVICE}:" | cut -d' ' -f1,2 | sed 's/: /-/g')
# trap "rmdir /run/user/$UID/mtp/$mtp_num_name" EXIT
mkdir -p /run/user/$UID/mtp/$mtp_num_name
simple-mtpfs --device "$DEVICE" /run/user/$UID/mtp/$mtp_num_name
elif [[ "$DEVICE" =~ ^[[:alpha:]] ]]; then
udisksctl mount --block-device "/dev/$DEVICE"
elif [[ $? -ne 0 ]]; then
mount-udisksctl-luks "$DEVICE"
fi
read -rsp $'Press any key to return to main menu\n' -n1 key
;;
u)
echo -n "Which device do you want to unmount? (e.g sdx1): "
read DEVICE
udisksctl unmount --force --block-device "/dev/$DEVICE"
if [ $? -ne 0 ]; then
if [[ "$DEVICE" = [0-9]* ]]; then
mtp_num_name=$(simple-mtpfs -l | grep "^${DEVICE}:" | cut -d' ' -f1,2 | sed 's/: /-/g')
fusermount -u /run/user/$UID/mtp/$mtp_num_name
rmdir /run/user/$UID/mtp/$mtp_num_name
elif [[ "$DEVICE" = [[:alpha:]]* ]]; then
udisksctl unmount --force --block-device "/dev/$DEVICE"
elif [[ $? -ne 0 ]]; then
unmount-udisksctl-luks "$DEVICE"
fi
read -rsp $'Press any key to return to main menu\n' -n1 key
Expand Down
6 changes: 5 additions & 1 deletion normal_user/scripts/.scripts/video2hevc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
# https://www.youtube.com/user/gotbletu

DIR=CONVERTED_MKVHEVC
helpmsg() {
Expand Down Expand Up @@ -30,7 +31,10 @@ else
# very clear (same as OG)
# ffmpeg -i "$arg" -c:v libx265 -preset medium -crf 23 -x265-params lossless -c:a copy -c:s copy "${arg%.*} x265 crf23.mkv"
# smaller file size, semi clear to OG
ffmpeg -i "$arg" -c:v libx265 -preset medium -crf 28 -x265-params lossless -c:a copy -c:s copy "$DIR/${arg%.*}.mkv"
# ffmpeg -i "$arg" -c:v libx265 -preset medium -crf 28 -x265-params lossless -c:a copy -c:s copy "$DIR/${arg%.*}.mkv"
# date--8/3/20 ffmpeg--2:4.3.1-1 x265--3.4-1
# ffmpeg -i "$arg" -c:v libx265 -preset medium -crf 28 -x265-params lossless=1 -c:a copy -c:s copy "$DIR/${arg%.*}.mkv"
ffmpeg -i "$arg" -c:v libx265 -preset medium -crf 28 -c:a copy -c:s copy "$DIR/${arg%.*}.mkv"
else
printf "%s\n" "$arg is invalid or output file already exist"
exit 1
Expand Down

0 comments on commit 1b77cc4

Please sign in to comment.