#!/bin/bash # upperLower2 # needs: xsel, awk # likes: notify-send # will upper, lower or capital 1st letter of X selection # and return the result to clipboard, removing xdotool completely # superecho superecho () { local msg="$1" if [[ -t 0 ]] ; then echo "$msg" else notify-send -t 3500 "$msg" fi } # get string from clipboard string="$(xsel)" # return changed string to clipboard backToClipboard () { echo -n "$1" | xsel --clipboard } # main if [[ "$1" == "-l" ]]; then # lower clip="${string,,}"; backToClipboard "$clip" superecho "$clip is back in clipboard, press ctrl+v" elif [[ "$1" == "-u" ]]; then # upper clip="${string^^}"; backToClipboard "$clip" superecho "$clip is back in clipboard, press ctrl+v" elif [[ "$1" == "-p" ]]; then # capital 1st clip="${string,,}" clip="$(echo "$clip" | awk '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1)) substr($i,2)}}1')" backToClipboard "$clip" superecho "$clip is back in clipboard, press ctrl+v" fi # openbox example if [[ "$1" == "--openbox" ]]; then cat < upperLower2 -l upperLower2 -u upperLower2 -p EOF fi