mirror of
				https://github.com/frebib/dotfiles.git
				synced 2024-06-14 12:57:23 +00:00 
			
		
		
		
	scripts/rofi-emoji: simplify clipboard/typing logic
Always do both, because that is the easiest thing to do
This commit is contained in:
		
							
								
								
									
										14
									
								
								scripts/rofi-emoji
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										14
									
								
								scripts/rofi-emoji
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							@@ -63,11 +63,6 @@ function download() {
 | 
				
			|||||||
    notify "$(basename "$0")" "We're all set!"
 | 
					    notify "$(basename "$0")" "We're all set!"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function toclip() {
 | 
					 | 
				
			||||||
    xclip -i -selection primary
 | 
					 | 
				
			||||||
    xclip -o -selection primary | xclip -i -selection clipboard
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function repeat() {
 | 
					function repeat() {
 | 
				
			||||||
    local rplc str="$1" count="$2"
 | 
					    local rplc str="$1" count="$2"
 | 
				
			||||||
    rplc="$(printf "%${count}s")"
 | 
					    rplc="$(printf "%${count}s")"
 | 
				
			||||||
@@ -85,7 +80,6 @@ function display() {
 | 
				
			|||||||
    update="⏫ Update emoji cache"
 | 
					    update="⏫ Update emoji cache"
 | 
				
			||||||
    emoji=$(printf "$emoji\n$update")
 | 
					    emoji=$(printf "$emoji\n$update")
 | 
				
			||||||
    line=$(echo "$emoji" | rofi -dmenu -i -p emoji -normal-window -kb-custom-1 Ctrl+c -kb-row-tab '' -kb-row-select Tab $@)
 | 
					    line=$(echo "$emoji" | rofi -dmenu -i -p emoji -normal-window -kb-custom-1 Ctrl+c -kb-row-tab '' -kb-row-select Tab $@)
 | 
				
			||||||
    exit_code=$?
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [ "${line[@]}" == "$update" ]; then
 | 
					    if [ "${line[@]}" == "$update" ]; then
 | 
				
			||||||
        download
 | 
					        download
 | 
				
			||||||
@@ -100,12 +94,10 @@ function display() {
 | 
				
			|||||||
    echo "$quantifier" | egrep -q '^[0-9]+$' || quantifier=1
 | 
					    echo "$quantifier" | egrep -q '^[0-9]+$' || quantifier=1
 | 
				
			||||||
    emojis="$(repeat "${line[0]}" "$quantifier")"
 | 
					    emojis="$(repeat "${line[0]}" "$quantifier")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [ $exit_code == 0 ]; then
 | 
					    sleep 0.1
 | 
				
			||||||
 | 
					    # Type the emojis, and put them in the clipboard
 | 
				
			||||||
    xdotool type --clearmodifiers "$emojis"
 | 
					    xdotool type --clearmodifiers "$emojis"
 | 
				
			||||||
        echo -n "$emojis" | xclip -i
 | 
					    printf "%s" "$emojis" | xclip -i -selection CLIPBOARD
 | 
				
			||||||
    elif [ $exit_code == 10 ]; then
 | 
					 | 
				
			||||||
        echo -n "$emojis" | xclip -i
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user