From 2918281b78de57a5147a4c1061f4330b41438deb Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 4 Sep 2023 15:24:31 -0400 Subject: [PATCH 1/9] Added cleaned-up version of convertHEICtoJPG.sh script designed to be run interactively or via cron --- bash/jpg | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 bash/jpg diff --git a/bash/jpg b/bash/jpg new file mode 100755 index 0000000..8a56216 --- /dev/null +++ b/bash/jpg @@ -0,0 +1,92 @@ +#!/bin/bash + +# Build instructions: +# https://medium.com/@eplt/5-minutes-to-install-imagemagick-with-heic-support-on-ubuntu-18-04-digitalocean-fe2d09dcef1 +# Command: +# https://zwbetz.com/convert-heic-images-to-jpg/ + +# trap ctrl-c and call ctrl_c() +# https://rimuhosting.com/knowledgebase/linux/misc/trapping-ctrl-c-in-bash +trap ctrl_c INT +function ctrl_c() { + echo "${rst}${red}CTRL+C Detected, exiting.${rst}" + exit +} + +padding=" " + +if [[ "${@}" == *"-h"* ]]; then + printf "%s\n" "Command usage:" + printf "$padding%-20s%s\n" "--dir [directory]" "Specify a directory other than current" + printf "$padding%-20s%s\n" "-d --delete" "Delete original files (default keeps originals)" + printf "$padding%-20s%s\n" "-q --quiet" "Suppresses progress output (summaries are still displayed)" + printf "$padding%-20s%s\n" "[--png|--jpg]" "Save as jpg/png (default is jpg)" + printf "$padding%-20s%s\n" "-h" "Print this help message and exit" + exit 0 +fi + +# DEFAULTS +# The folder with the files you want to convert +directory="`pwd`" +# Set to 0 to delete the original .heic files after they are converted +keeporiginals=1 +# Set to 0 for PNG (much larger file size) +saveasjpg=1 +# Suppress progress output +keepquiet=0 + +customdir=0 +for _arg in ${@}; do + if [ $customdir -eq 1 ]; then directory="$_arg"; customdir=2; continue; fi + if [ "$_arg" == "--dir" ]; then customdir=1; continue; fi + if [ "$_arg" == "-d" ]; then keeporiginals=0; continue; fi + if [ "$_arg" == "--delete" ]; then keeporiginals=0; continue; fi + if [ "$_arg" == "-q" ]; then keepquiet=1; continue; fi + if [ "$_arg" == "--quiet" ]; then keepquiet=1; continue; fi + if [ "$_arg" == "--png" ]; then saveasjpg=0; continue; fi + if [ "$_arg" == "--jpg" ]; then saveasjpg=1; continue; fi +done + +# summary: +printf "\n%s\n" "Summary:" +printf "$padding%s\n" "Directory: $directory" +[ $keeporiginals -eq 0 ] && printf "$padding%s\n" "Originals: Delete" || printf "$padding%s\n" "Originals: Keep" +[ $keepquiet -eq 0 ] && printf "$padding%s\n" "Output: Visible" || printf "$padding%s\n" "Output: Hidden" +[ $saveasjpg -eq 0 ] && printf "$padding%s\n" "Save as: PNG" || printf "$padding%s\n" "Save as: JPG" +printf "\n%s" "Press enter to begin or ^c to exit" +read + +# Make sure the mogrify command is available. If this is being +# run as a cron job the which command will fail so we check the +# default location just in case. +which mogrify > /dev/null +if [[ $? -eq 1 ]]; then + if [[ ! -e "/usr/local/bin/mogrify" ]]; then + echo "Unable to run the mogrify command. Please follow the build and installation instructions at the top of the script to install the program on your system." + exit + fi +fi + +filecount=0 +[ $saveasjpg -eq 0 ] && destformat="png" || destformat="jpg" +# Loop over all the .heic files in the folder +for heic in *.heic; do + # Drop the .heic extension and append .jpg instead + img=`echo "$heic" | rev | cut -d. -f2- | rev`.$destformat + if [ -f "$img" ]; then [ $keepquiet -eq 0 ] && printf "%s\n" "Skipping $heic ($img exists)" + else [ $keepquiet -eq 0 ] && printf "%s\n" "Converting $heic to $img"; fi + [ -f "$img" ] || let filecount=filecount+1 + # If the file we are going to make does not exist, run the command to convert it + [ -f "$img" ] || /usr/local/bin/mogrify -format $destformat "$heic" + # If we don't want the originals, give them the axe + [ $keeporiginals -eq 0 ] && rm "$heic" +done + +if [ $filecount -gt 0 ]; then + printf "\n%s\n\n" "Script complete. Converted $filecount heic files to $destformat" +else + if [ $customdir -eq 2 ]; then + printf "\n%s\n\n" "Found 0 heic files to convert. Are you sure you specified the right directory?" + else + printf "\n%s\n\n" "Found 0 heic files to convert. Are you sure you're in the right directory?" +fi From a6809e4cfae440c153bf82295368a41b28c6a47e Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 4 Sep 2023 15:43:47 -0400 Subject: [PATCH 2/9] Moved mogrify bin check to make more sense --- bash/jpg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bash/jpg b/bash/jpg index 8a56216..ba9d088 100755 --- a/bash/jpg +++ b/bash/jpg @@ -47,15 +47,6 @@ for _arg in ${@}; do if [ "$_arg" == "--jpg" ]; then saveasjpg=1; continue; fi done -# summary: -printf "\n%s\n" "Summary:" -printf "$padding%s\n" "Directory: $directory" -[ $keeporiginals -eq 0 ] && printf "$padding%s\n" "Originals: Delete" || printf "$padding%s\n" "Originals: Keep" -[ $keepquiet -eq 0 ] && printf "$padding%s\n" "Output: Visible" || printf "$padding%s\n" "Output: Hidden" -[ $saveasjpg -eq 0 ] && printf "$padding%s\n" "Save as: PNG" || printf "$padding%s\n" "Save as: JPG" -printf "\n%s" "Press enter to begin or ^c to exit" -read - # Make sure the mogrify command is available. If this is being # run as a cron job the which command will fail so we check the # default location just in case. @@ -67,6 +58,15 @@ if [[ $? -eq 1 ]]; then fi fi +# summary: +printf "\n%s\n" "Summary:" +printf "$padding%s\n" "Directory: $directory" +[ $keeporiginals -eq 0 ] && printf "$padding%s\n" "Originals: Delete" || printf "$padding%s\n" "Originals: Keep" +[ $keepquiet -eq 0 ] && printf "$padding%s\n" "Output: Visible" || printf "$padding%s\n" "Output: Hidden" +[ $saveasjpg -eq 0 ] && printf "$padding%s\n" "Save as: PNG" || printf "$padding%s\n" "Save as: JPG" +printf "\n%s" "Press enter to begin or ^c to exit" +read + filecount=0 [ $saveasjpg -eq 0 ] && destformat="png" || destformat="jpg" # Loop over all the .heic files in the folder From e8ec713333a5c3eaa9ceb9d9d57d4e0a1dff5431 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 4 Sep 2023 15:55:16 -0400 Subject: [PATCH 3/9] It's the little things... --- bash/jpg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bash/jpg b/bash/jpg index ba9d088..854ccea 100755 --- a/bash/jpg +++ b/bash/jpg @@ -83,7 +83,10 @@ for heic in *.heic; do done if [ $filecount -gt 0 ]; then - printf "\n%s\n\n" "Script complete. Converted $filecount heic files to $destformat" + if [ $filecount -eq 1 ]; then + printf "\n%s\n\n" "Script complete. Converted $filecount heic file to $destformat" + else + printf "\n%s\n\n" "Script complete. Converted $filecount heic files to $destformat" else if [ $customdir -eq 2 ]; then printf "\n%s\n\n" "Found 0 heic files to convert. Are you sure you specified the right directory?" From edad99ba39979e981928bb7683e3eb5c714c84b2 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 4 Sep 2023 15:55:54 -0400 Subject: [PATCH 4/9] Fixed a fi --- bash/jpg | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/jpg b/bash/jpg index 854ccea..55061ac 100755 --- a/bash/jpg +++ b/bash/jpg @@ -87,6 +87,7 @@ if [ $filecount -gt 0 ]; then printf "\n%s\n\n" "Script complete. Converted $filecount heic file to $destformat" else printf "\n%s\n\n" "Script complete. Converted $filecount heic files to $destformat" + fi else if [ $customdir -eq 2 ]; then printf "\n%s\n\n" "Found 0 heic files to convert. Are you sure you specified the right directory?" From 775455af11e769bee9e3f9a655ba8a2943dbbd87 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 4 Sep 2023 16:22:31 -0400 Subject: [PATCH 5/9] Added better help text, cleaned up ctrl+c, and fixed more fis --- bash/jpg | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/bash/jpg b/bash/jpg index 55061ac..cb78678 100755 --- a/bash/jpg +++ b/bash/jpg @@ -5,23 +5,33 @@ # Command: # https://zwbetz.com/convert-heic-images-to-jpg/ +red="$(tput setaf 1)" +rst="$(tput sgr0)" + # trap ctrl-c and call ctrl_c() # https://rimuhosting.com/knowledgebase/linux/misc/trapping-ctrl-c-in-bash trap ctrl_c INT function ctrl_c() { - echo "${rst}${red}CTRL+C Detected, exiting.${rst}" + if [ $filecount -eq 0 ]; then printf "%s\n" "${rst}${red}exiting${rst}" + else printf "\n%s\n%s\n\n" "${rst}${red}CTRL+C detected - this may have corrupted the most recent attempted file" "conversion. Please inspect the latest file and delete or retry as needed.${rst}" + fi exit } padding=" " if [[ "${@}" == *"-h"* ]]; then + printf "%s\n" "Command:" + printf "$padding%s\n" "Converts heic files (Apple's native picture format) to either jpg (default)" + printf "$padding%s\n" "or png (larger file size) for easier manipulation or sharing. Requires that" + printf "$padding%s\n" "Imagemagick's mogrify tool be complied and installed with heic support. See" + printf "$padding%s\n" "step 1 at https://dismy.link/heicmogrify for a brief install guide." printf "%s\n" "Command usage:" printf "$padding%-20s%s\n" "--dir [directory]" "Specify a directory other than current" printf "$padding%-20s%s\n" "-d --delete" "Delete original files (default keeps originals)" printf "$padding%-20s%s\n" "-q --quiet" "Suppresses progress output (summaries are still displayed)" printf "$padding%-20s%s\n" "[--png|--jpg]" "Save as jpg/png (default is jpg)" - printf "$padding%-20s%s\n" "-h" "Print this help message and exit" + printf "$padding%-20s%s\n" "-h --help" "Print this help message and exit" exit 0 fi @@ -35,6 +45,7 @@ saveasjpg=1 # Suppress progress output keepquiet=0 +filecount=0 customdir=0 for _arg in ${@}; do if [ $customdir -eq 1 ]; then directory="$_arg"; customdir=2; continue; fi @@ -50,16 +61,22 @@ done # Make sure the mogrify command is available. If this is being # run as a cron job the which command will fail so we check the # default location just in case. +mymogrify=`which mogrify` which mogrify > /dev/null if [[ $? -eq 1 ]]; then - if [[ ! -e "/usr/local/bin/mogrify" ]]; then - echo "Unable to run the mogrify command. Please follow the build and installation instructions at the top of the script to install the program on your system." - exit + if [[ -e "/usr/local/bin/mogrify" ]]; then + mymogrify="/usr/local/bin/mogrify" + else + printf "%s\n" "Unable to locate the mogrify command. Please follow the build and" + printf "%s\n" "installation guide at https://dismy.link/heicmogrify to install" + printf "%s\n" "the ImageMagick mogfify tool on your system with heic support." + exit 1 fi fi # summary: printf "\n%s\n" "Summary:" +printf "$padding%s\n" "Binary: $mymogrify" printf "$padding%s\n" "Directory: $directory" [ $keeporiginals -eq 0 ] && printf "$padding%s\n" "Originals: Delete" || printf "$padding%s\n" "Originals: Keep" [ $keepquiet -eq 0 ] && printf "$padding%s\n" "Output: Visible" || printf "$padding%s\n" "Output: Hidden" @@ -67,7 +84,6 @@ printf "$padding%s\n" "Directory: $directory" printf "\n%s" "Press enter to begin or ^c to exit" read -filecount=0 [ $saveasjpg -eq 0 ] && destformat="png" || destformat="jpg" # Loop over all the .heic files in the folder for heic in *.heic; do @@ -77,7 +93,14 @@ for heic in *.heic; do else [ $keepquiet -eq 0 ] && printf "%s\n" "Converting $heic to $img"; fi [ -f "$img" ] || let filecount=filecount+1 # If the file we are going to make does not exist, run the command to convert it - [ -f "$img" ] || /usr/local/bin/mogrify -format $destformat "$heic" + if [ ! -f "$img" ]; then + $mymogrify -format $destformat "$heic" + mogrified=$? + if [ $mogrified -ne 0 ]; then + printf "\n%s\n\n" "${rst}${red}Encountered the above error while trying to mogrify. Exiting.${rst}" + exit $mogrified + fi + fi # If we don't want the originals, give them the axe [ $keeporiginals -eq 0 ] && rm "$heic" done @@ -93,4 +116,5 @@ else printf "\n%s\n\n" "Found 0 heic files to convert. Are you sure you specified the right directory?" else printf "\n%s\n\n" "Found 0 heic files to convert. Are you sure you're in the right directory?" + fi fi From 38ef97673645c273af403f49fb2fb4c49c590924 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 11 Sep 2023 10:49:03 -0400 Subject: [PATCH 6/9] Added my bash profile with powerline funtimes --- bash/bash-profile | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 bash/bash-profile diff --git a/bash/bash-profile b/bash/bash-profile new file mode 100644 index 0000000..9586de1 --- /dev/null +++ b/bash/bash-profile @@ -0,0 +1,69 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + + +# Show all colors: +# https://askubuntu.com/a/1309434 +# for colour in {1..225}; do echo -en "\033[38;5;${colour}m38;5;${colour} \n"; done | column -x + +# Powerline prompts require a powerline (PL) supporting font such as Microsoft's Cascadia/Cascadia Code +# https://github.com/microsoft/cascadia-code + +# POWERLINE PROMPTS +# HOSTTEXT=HOST TEXT COLOR +# USERTEXT=USER TEXT COLOR # NOT IMPLEMENTED +# COLORA = PATH BACKGROUND +# COLORB = PATH TEXT COLOR +# COLORC = HOST BACKGROUND +# COLORD = USER BACKGROUND +## RED +#hosttext="5;15m";colora="5;203m"; colorb="5;15m"; colorc="5;124m"; colord="5;160m" +## BLUE +#hosttext="5;15m";colora="5;250m"; colorb="5;15m"; colorc="5;27m"; colord="5;39m" +## GREEN +#hosttext="5;15m"; colora="5;15m"; colorb="5;00m"; colorc="5;22m"; colord="5;28m" +## BEACHY +hosttext="5;15m"; colora="5;250m"; colorb="5;00m"; colorc="5;214m"; colord="5;39m" +## ORANGE +#hosttext="5;15m"; colora="5;15m"; colorb="5;00m"; colorc="5;214m"; colord="5;220m" +## DARK +#hosttext="5;15m"; colora="5;250m"; colorb="5;00m"; colorc="5;234m"; colord="5;239m" +## PORMPT MAGIX +_me=`/bin/whoami` +[ "$_me" == "root" ] && _home=/root || _home=/home/$_me +resetpl="\[\033[00m\]" +promptfg="\[\033[38;${hosttext}\]" +pathfg="\[\033[38;${colorb}\]" +hostbg="\[\033[48;${colorc}\]" +hostuserpl="\[\033[48;${colord}\]\[\033[38;${colorc}\]" +userpathpl="\[\033[48;${colora}\]\[\033[38;${colord}\]" +pathpromptpl="${resetpl}\[\033[38;${colora}\]" +PROMPT_COMMAND='_dir=`pwd | sed "s|^$_home|~|g"`;if [ ${#_dir} -ge 35 ]; then _mydir=`pwd | cut -c1-16`; _mydir=${_mydir}.../`pwd | rev | cut -d/ -f1 | rev`; else _mydir=`pwd`; fi; _mydir=`echo $_mydir | sed "s|^$_home|~|g"`; PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}${hostbg}${promptfg}\h${hostuserpl}${promptfg}\u${userpathpl}${pathfg}${_mydir}${resetpl}${pathpromptpl}${resetpl} "' +# https://stackoverflow.com/a/19152051 (for pipes in sed ^^) + +alias explorer="explorer.exe" From 6611ad8c7935ecdba3260139d07ac86a5438f1bb Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 11 Sep 2023 10:51:20 -0400 Subject: [PATCH 7/9] Added comment to profile --- bash/bash-profile | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/bash-profile b/bash/bash-profile index 9586de1..64da874 100644 --- a/bash/bash-profile +++ b/bash/bash-profile @@ -66,4 +66,5 @@ pathpromptpl="${resetpl}\[\033[38;${colora}\]" PROMPT_COMMAND='_dir=`pwd | sed "s|^$_home|~|g"`;if [ ${#_dir} -ge 35 ]; then _mydir=`pwd | cut -c1-16`; _mydir=${_mydir}.../`pwd | rev | cut -d/ -f1 | rev`; else _mydir=`pwd`; fi; _mydir=`echo $_mydir | sed "s|^$_home|~|g"`; PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}${hostbg}${promptfg}\h${hostuserpl}${promptfg}\u${userpathpl}${pathfg}${_mydir}${resetpl}${pathpromptpl}${resetpl} "' # https://stackoverflow.com/a/19152051 (for pipes in sed ^^) +# Useful for WSL to open windows file explorer in the current directory (e.g. explorer .) alias explorer="explorer.exe" From db4f8d1d9d25c722db1781d610f2462d2e75d437 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 10 Nov 2023 19:28:17 -0500 Subject: [PATCH 8/9] Added registry key for Notepad2 --- apptweaks/windows/EditWithNotepad2.reg | Bin 0 -> 304 bytes autohotkey/RemapWindowsShortcuts.ahk | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100755 apptweaks/windows/EditWithNotepad2.reg diff --git a/apptweaks/windows/EditWithNotepad2.reg b/apptweaks/windows/EditWithNotepad2.reg new file mode 100755 index 0000000000000000000000000000000000000000..6292f1d69559e3cb88a0188d6602ccc0b3fb2b62 GIT binary patch literal 304 zcmZXPK?{OV5QOI(^dBBVmkv@vmmnxY2#Sh|A~HlOQb-LIsy|kj~o=6`{Pqp=9ErkPUiFonaCX+Ko@vZ=|6ddJawlvac2U eW!#W6m*7%y|62c?i`R>&w2XaQ>e}qo*Zlx;kTTT( literal 0 HcmV?d00001 diff --git a/autohotkey/RemapWindowsShortcuts.ahk b/autohotkey/RemapWindowsShortcuts.ahk index c9bf44b..7df5cf0 100644 --- a/autohotkey/RemapWindowsShortcuts.ahk +++ b/autohotkey/RemapWindowsShortcuts.ahk @@ -1,6 +1,6 @@ -; Replace with the pat to Explorer++ -; https://explorerplusplus.com/ -#e::run, "A:\Programs\ExplorerPP\Explorer++.exe" +; Replace with the pat to dopus +; dopus +#d::run, "A:\Programs\GPSoftware\Directory Opus\dopus.exe" ; Replace with the path to Everything ; https://www.voidtools.com/ From 220ec4a6244b1f350bf4e3a826c988062a714568 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 24 Nov 2023 13:28:31 -0500 Subject: [PATCH 9/9] Added deck suspend video css fix script --- bash/fix-suspend-video-size.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 bash/fix-suspend-video-size.sh diff --git a/bash/fix-suspend-video-size.sh b/bash/fix-suspend-video-size.sh new file mode 100644 index 0000000..29c5fb7 --- /dev/null +++ b/bash/fix-suspend-video-size.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# presently not working - the file changes, but it looks like the +# steam client is re-verifying them when it boots which instantly +# undoes the changes that we made. Maybe one day there'll be some +# way to persist the change. + +stpath='/home/deck/.local/share/Steam/steamui/css' +cssboi='chunk~2dcc5aaf7.css' + +if [ ! -f $stpath/$cssboi ]; then + printf "\n%s\n\n" "chunk file '$cssboi' not found, please fix file location in $0. Listing directory $stpath for reference:" + ls $stpath + printf "\n" + exit 1 +fi + +printf "\n%s\n" "Updating $cssboi..." +sed -i 's/.powermenu_SuspendVideo_s11wN{flex-grow:0;width:300px;height:300px}/.powermenu_SuspendVideo_s11wN{flex-grow:1;width100%;height:100%}/' $stpath/$cssboi +printf "\n%s\n\n" "Done!"