From b7f4c6c54d55a8dfdb67152521405346fbde2289 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 12 Feb 2021 20:53:06 -0600 Subject: [PATCH] - Refined Back/Forward/Undo Text/Tabs config for Linux --- linux/browsers.sh | 57 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/linux/browsers.sh b/linux/browsers.sh index d1e3794..309a548 100755 --- a/linux/browsers.sh +++ b/linux/browsers.sh @@ -5,37 +5,60 @@ action=$1 saveClipboard=$(xclip -selection clipboard -o) echo "" | xclip -i -selection clipboard if [ "$action" == "Left" ];then - xdotool getactivewindow key --delay 40 --clearmodifiers End bar Shift+Left ctrl+x + xdotool getactivewindow key --delay 40 --clearmodifiers End Shift+Left ctrl+c + firstClipboard=$(xclip -selection clipboard -o) + if [ "${#firstClipboard}" > 1 ];then + firstClipboard=${firstClipboard: -1} + fi + echo "" | xclip -i -selection clipboard + xdotool getactivewindow key --delay 24 --clearmodifiers Left Shift+Right ctrl+c Right fi -if [ "$action" == "Right" ];then - xdotool getactivewindow key --delay 40 --clearmodifiers Home bar Shift+Left ctrl+x -fi -if [ "$action" == "Undo" ];then - xdotool getactivewindow key --delay 24 --clearmodifiers bar Shift+Left ctrl+x - sleep 0.1 +if [ "$action" == "Right" ] || [ "$action" == "Undo" ];then + xdotool getactivewindow key --delay 40 --clearmodifiers Home Shift+Right ctrl+c + firstClipboard=$(xclip -selection clipboard -o) + if [ "${#firstClipboard}" > 1 ];then + firstClipboard=${firstClipboard:0:1} + fi + echo "" | xclip -i -selection clipboard + xdotool getactivewindow key --delay 24 --clearmodifiers Right Shift+Left ctrl+c Left fi newClipboard=$(xclip -selection clipboard -o) -# echo "$newClipboard" +# echo ${#firstClipboard} +# echo "$firstClipboard""-" +# echo "first" +# echo ${#newClipboard} +# echo "$newClipboard""-" # echo "hello" -if [ "$newClipboard" != "|" ] && [ "$action" == "Left" ];then - xdotool getactivewindow key --clearmodifiers alt+Left -elif [ "$action" == "Left" ];then +if [ "$action" == "Undo" ] && [ "$newClipboard" == "" ] && [ "$firstClipboard" == "" ];then + xdotool getactivewindow key --delay 24 --clearmodifiers bar Shift+Left ctrl+c Left + firstClipboard=$(xclip -selection clipboard -o) + echo "" | xclip -i -selection clipboard + xdotool getactivewindow key --delay 24 --clearmodifiers Shift+Right ctrl+x + newClipboard=$(xclip -selection clipboard -o) + if [ "$newClipboard" != "" ] && [ "$firstClipboard" != "" ];then + xdotool getactivewindow key --delay 24 --clearmodifiers ctrl+z ctrl+z + fi +fi + +if [ "$action" == "Left" ] && [ "$newClipboard" != "" ] && [ "$newClipboard" == "$firstClipboard" ];then xdotool getactivewindow key --clearmodifiers Home +elif [ "$action" == "Left" ];then + xdotool getactivewindow key --clearmodifiers alt+Left fi -if [ "$newClipboard" != "|" ] && [ "$action" == "Right" ];then - xdotool getactivewindow key --clearmodifiers alt+Right -elif [ "$action" == "Right" ];then +if [ "$action" == "Right" ] && [ "$newClipboard" != "" ] && [ "$newClipboard" == "$firstClipboard" ];then xdotool getactivewindow key --clearmodifiers End +elif [ "$action" == "Right" ];then + xdotool getactivewindow key --clearmodifiers alt+Right fi -if [ "$newClipboard" != "|" ] && [ "$action" == "Undo" ];then - xdotool getactivewindow key ctrl+Shift+t +if [ "$action" == "Undo" ] && [ "$newClipboard" != "" ] && [ "$newClipboard" == "$firstClipboard" ];then + xdotool getactivewindow key --delay 24 --clearmodifiers ctrl+z elif [ "$action" == "Undo" ];then - xdotool getactivewindow key --delay 24 --clearmodifiers ctrl+z ctrl+z ctrl+z + xdotool getactivewindow key ctrl+Shift+t fi echo $saveClipboard | xclip -i -selection clipboard \ No newline at end of file