fixing rofi-rbw sorting
This commit is contained in:
		
							parent
							
								
									d2938b8004
								
							
						
					
					
						commit
						7a1f2a50b4
					
				
					 9 changed files with 1 additions and 476 deletions
				
			
		| 
						 | 
				
			
			@ -1,71 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
# Very basic interface for rbw using rofi
 | 
			
		||||
 | 
			
		||||
if [ $(hostname) = "syl" ]; then
 | 
			
		||||
    style="laptop-rbw-wayland"
 | 
			
		||||
    #echo "this is hidpi"
 | 
			
		||||
else 
 | 
			
		||||
    style="desktop-rbw"
 | 
			
		||||
    #echo "this is not hidpi"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Get all password files and create an array
 | 
			
		||||
root=~/.password-store
 | 
			
		||||
CACHE=~/.local/tmp/pass_rofi
 | 
			
		||||
seat=seat0
 | 
			
		||||
 | 
			
		||||
rbw sync
 | 
			
		||||
rbw list
 | 
			
		||||
 | 
			
		||||
list_passwords() {
 | 
			
		||||
    rbw list
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
passwords=$(rbw list)
 | 
			
		||||
 | 
			
		||||
prompt='search for passwords...'
 | 
			
		||||
SECRET=$(list_passwords | rofi -i -p="${prompt}" -dmenu -theme ~/.config/rofi/launchers-git/$style.rasi)
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
 | 
			
		||||
options=("Password" \
 | 
			
		||||
             "User" \
 | 
			
		||||
             "User and password" \
 | 
			
		||||
             "QR-Code" \
 | 
			
		||||
	     "OTP")
 | 
			
		||||
 | 
			
		||||
option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt="..." -theme ~/.config/rofi/launchers-git/$style.rasi)
 | 
			
		||||
 | 
			
		||||
echo $option
 | 
			
		||||
 | 
			
		||||
case ${option} in
 | 
			
		||||
    Password )
 | 
			
		||||
	echo "${SECRET}"
 | 
			
		||||
	ydotool type $(rbw get "${SECRET}")
 | 
			
		||||
	;;
 | 
			
		||||
    User )
 | 
			
		||||
	ydotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	;;
 | 
			
		||||
    "User and password" )
 | 
			
		||||
	ydotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	ydotool key Tab
 | 
			
		||||
	ydotool type $(rbw get "${SECRET}")
 | 
			
		||||
	;;
 | 
			
		||||
    "QR-Code" )
 | 
			
		||||
	if [[ $SECRET =~ wifi$ ]]; then
 | 
			
		||||
	    # Produce a valid wifi QR-code
 | 
			
		||||
	    WIFISSID=$(pass get_user ${SECRET})
 | 
			
		||||
	    WIFIPASS=$(pass get_pass ${SECRET})
 | 
			
		||||
	    WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
 | 
			
		||||
	    qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
 | 
			
		||||
	else
 | 
			
		||||
	    # Only password
 | 
			
		||||
	    pass show -q1 ${SECRET}
 | 
			
		||||
	fi
 | 
			
		||||
	;;
 | 
			
		||||
    "OTP" )
 | 
			
		||||
	ydotool type $(rbw code ${SECRET})
 | 
			
		||||
	;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# wl-copy -o -s ${seat} ${PASSWD_PASS}
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ list_passwords() {
 | 
			
		|||
 | 
			
		||||
passwords=$(rbw list)
 | 
			
		||||
 | 
			
		||||
SECRET=$(list_passwords | rofi -sync -i -dmenu -p "" )
 | 
			
		||||
SECRET=$(list_passwords | rofi -sync -i -dmenu -sort -p "" )
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,87 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
# Very basic interface for rbw using rofi
 | 
			
		||||
 | 
			
		||||
if [ $(hostname) = "syl" ]; then
 | 
			
		||||
    style="laptop-rbw"
 | 
			
		||||
    #echo "this is hidpi"
 | 
			
		||||
else 
 | 
			
		||||
    style="desktop-rbw"
 | 
			
		||||
    #echo "this is not hidpi"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Get all password files and create an array
 | 
			
		||||
root=~/.password-store
 | 
			
		||||
CACHE=~/.local/tmp/pass_rofi
 | 
			
		||||
seat=seat0
 | 
			
		||||
 | 
			
		||||
# rbw sync
 | 
			
		||||
rbw list
 | 
			
		||||
 | 
			
		||||
list_passwords() {
 | 
			
		||||
    rbw list
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
passwords=$(rbw list)
 | 
			
		||||
 | 
			
		||||
prompt='search for passwords...'
 | 
			
		||||
SECRET=$(list_passwords | rofi -i -p="${prompt}" -dmenu -theme ~/.config/rofi/launchers-git/$style.rasi $@ &
 | 
			
		||||
         c=0
 | 
			
		||||
         while ! xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $(xdotool search -class 'rofi') ; do
 | 
			
		||||
             sleep .1 
 | 
			
		||||
             c=$((c+1))
 | 
			
		||||
             [[ c = 50 ]] && exit; # stop script window didn't appear after 5 seconds
 | 
			
		||||
         done
 | 
			
		||||
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
 | 
			
		||||
options=("Password" \
 | 
			
		||||
             "User" \
 | 
			
		||||
             "User and password" \
 | 
			
		||||
             "QR-Code" \
 | 
			
		||||
	     "OTP")
 | 
			
		||||
 | 
			
		||||
option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt="..." -theme ~/.config/rofi/launchers-git/$style.rasi $@ &
 | 
			
		||||
         c=0
 | 
			
		||||
         while ! xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $(xdotool search -class 'rofi') ; do
 | 
			
		||||
             sleep .1 
 | 
			
		||||
             c=$((c+1))
 | 
			
		||||
             [[ c = 50 ]] && exit; # stop script window didn't appear after 5 seconds
 | 
			
		||||
         done
 | 
			
		||||
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
echo $option
 | 
			
		||||
 | 
			
		||||
case ${option} in
 | 
			
		||||
    Password )
 | 
			
		||||
	echo "${SECRET}"
 | 
			
		||||
	xdotool type $(rbw get "${SECRET}")
 | 
			
		||||
	;;
 | 
			
		||||
    User )
 | 
			
		||||
	xdotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	;;
 | 
			
		||||
    "User and password" )
 | 
			
		||||
	xdotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	xdotool key Tab
 | 
			
		||||
	xdotool type $(rbw get "${SECRET}")
 | 
			
		||||
	;;
 | 
			
		||||
    "QR-Code" )
 | 
			
		||||
	if [[ $SECRET =~ wifi$ ]]; then
 | 
			
		||||
	    # Produce a valid wifi QR-code
 | 
			
		||||
	    WIFISSID=$(pass get_user ${SECRET})
 | 
			
		||||
	    WIFIPASS=$(pass get_pass ${SECRET})
 | 
			
		||||
	    WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
 | 
			
		||||
	    qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
 | 
			
		||||
	else
 | 
			
		||||
	    # Only password
 | 
			
		||||
	    pass show -q1 ${SECRET}
 | 
			
		||||
	fi
 | 
			
		||||
	;;
 | 
			
		||||
    "OTP" )
 | 
			
		||||
	xdotool type $(rbw code ${SECRET})
 | 
			
		||||
	;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# wl-copy -o -s ${seat} ${PASSWD_PASS}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,62 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
# Very basic interface for pass using wofi
 | 
			
		||||
 | 
			
		||||
# Get all password files and create an array
 | 
			
		||||
root=~/.password-store
 | 
			
		||||
CACHE=~/.local/tmp/pass_wofi
 | 
			
		||||
seat=seat0
 | 
			
		||||
 | 
			
		||||
list_passwords() {
 | 
			
		||||
    shopt -s nullglob globstar
 | 
			
		||||
	cd "${root}" || exit
 | 
			
		||||
	pw_list=(**/*.gpg)
 | 
			
		||||
	printf '%s\n' "${pw_list[@]%.gpg}" | sort -n
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
prompt='search for passwords...'
 | 
			
		||||
SECRET=$(list_passwords | rofi -i -prompt="${prompt}" -dmenu)
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
 | 
			
		||||
options=("Password" \
 | 
			
		||||
        "User" \
 | 
			
		||||
        "User and password" \
 | 
			
		||||
        "QR-Code" \
 | 
			
		||||
	"OTP")
 | 
			
		||||
 | 
			
		||||
option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt="...")
 | 
			
		||||
 | 
			
		||||
echo $option
 | 
			
		||||
 | 
			
		||||
case ${option} in
 | 
			
		||||
    Password )
 | 
			
		||||
	echo "Test"
 | 
			
		||||
	wtype $(pass ${SECRET} | head -n 1)
 | 
			
		||||
	;;
 | 
			
		||||
    User )
 | 
			
		||||
	wtype $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	;;
 | 
			
		||||
    "User and password" )
 | 
			
		||||
	wtype $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	wtype -k TAB
 | 
			
		||||
	wtype $(pass ${SECRET} | head -n 1)
 | 
			
		||||
	;;
 | 
			
		||||
    "QR-Code" )
 | 
			
		||||
	if [[ $SECRET =~ wifi$ ]]; then
 | 
			
		||||
	    # Produce a valid wifi QR-code
 | 
			
		||||
	    WIFISSID=$(pass get_user ${SECRET})
 | 
			
		||||
	    WIFIPASS=$(pass get_pass ${SECRET})
 | 
			
		||||
	    WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
 | 
			
		||||
	    qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
 | 
			
		||||
	else
 | 
			
		||||
	    # Only password
 | 
			
		||||
	    pass show -q1 ${SECRET}
 | 
			
		||||
	fi
 | 
			
		||||
	;;
 | 
			
		||||
    "OTP" )
 | 
			
		||||
	wtype $(pass otp ${SECRET})
 | 
			
		||||
	;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# wl-copy -o -s ${seat} ${PASSWD_PASS}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,62 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
# Very basic interface for pass using wofi
 | 
			
		||||
 | 
			
		||||
# Get all password files and create an array
 | 
			
		||||
root=~/.password-store
 | 
			
		||||
CACHE=~/.local/tmp/pass_wofi
 | 
			
		||||
seat=seat0
 | 
			
		||||
 | 
			
		||||
list_passwords() {
 | 
			
		||||
    shopt -s nullglob globstar
 | 
			
		||||
	cd "${root}" || exit
 | 
			
		||||
	pw_list=(**/*.gpg)
 | 
			
		||||
	printf '%s\n' "${pw_list[@]%.gpg}" | sort -n
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
prompt='passwords'
 | 
			
		||||
SECRET=$(list_passwords | rofi -i -p "${prompt}" -dmenu)
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
 | 
			
		||||
options=("Password" \
 | 
			
		||||
        "User" \
 | 
			
		||||
        "User and password" \
 | 
			
		||||
        "QR-Code" \
 | 
			
		||||
	"OTP")
 | 
			
		||||
 | 
			
		||||
option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt "...")
 | 
			
		||||
 | 
			
		||||
echo $option
 | 
			
		||||
 | 
			
		||||
case ${option} in
 | 
			
		||||
    Password )
 | 
			
		||||
	echo "Test"
 | 
			
		||||
	xdotool type $(pass ${SECRET} | head -n 1)
 | 
			
		||||
	;;
 | 
			
		||||
    User )
 | 
			
		||||
	xdotool type $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	;;
 | 
			
		||||
    "User and password" )
 | 
			
		||||
	xdotool type $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	xdotool key TAB
 | 
			
		||||
	xdotool type $(pass ${SECRET} | head -n 1)
 | 
			
		||||
	;;
 | 
			
		||||
    "QR-Code" )
 | 
			
		||||
	if [[ $SECRET =~ wifi$ ]]; then
 | 
			
		||||
	    # Produce a valid wifi QR-code
 | 
			
		||||
	    WIFISSID=$(pass get_user ${SECRET})
 | 
			
		||||
	    WIFIPASS=$(pass get_pass ${SECRET})
 | 
			
		||||
	    WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
 | 
			
		||||
	    qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
 | 
			
		||||
	else
 | 
			
		||||
	    # Only password
 | 
			
		||||
	    pass show -q1 ${SECRET}
 | 
			
		||||
	fi
 | 
			
		||||
	;;
 | 
			
		||||
    "OTP" )
 | 
			
		||||
	xdotool type $(pass otp ${SECRET})
 | 
			
		||||
	;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# wl-copy -o -s ${seat} ${PASSWD_PASS}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,69 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
# Very basic interface for rbw using rofi
 | 
			
		||||
if [ $(hostname) = "syl" ]; then
 | 
			
		||||
    style="laptop-rbw"
 | 
			
		||||
    #echo "this is hidpi"
 | 
			
		||||
else 
 | 
			
		||||
    style="desktop-rbw"
 | 
			
		||||
    #echo "this is not hidpi"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Get all password files and create an array
 | 
			
		||||
root=~/.password-store
 | 
			
		||||
CACHE=~/.local/tmp/pass_rofi
 | 
			
		||||
seat=seat0
 | 
			
		||||
 | 
			
		||||
rbw sync
 | 
			
		||||
rbw list
 | 
			
		||||
 | 
			
		||||
list_passwords() {
 | 
			
		||||
    rbw list
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
passwords=$(rbw list)
 | 
			
		||||
 | 
			
		||||
prompt='search for passwords...'
 | 
			
		||||
SECRET=$(list_passwords | wofi -i -p"${prompt}" -d)
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
options=("Password" \
 | 
			
		||||
             "User" \
 | 
			
		||||
             "User and password" \
 | 
			
		||||
             "QR-Code" \
 | 
			
		||||
	     "OTP")
 | 
			
		||||
 | 
			
		||||
option=$(printf '%s\n' "${options[@]%}" | wofi -id -W 400 -H 150 -p"...")
 | 
			
		||||
 | 
			
		||||
# echo $option
 | 
			
		||||
 | 
			
		||||
case ${option} in
 | 
			
		||||
    Password )
 | 
			
		||||
	# echo "${SECRET}"
 | 
			
		||||
	ydotool type --next-delay 500 $(rbw get "${SECRET}")
 | 
			
		||||
	;;
 | 
			
		||||
    User )
 | 
			
		||||
	ydotool type --next-delay 500 "$(rbw get --full "${SECRET}" | rg Username: | awk '{print $2}')"
 | 
			
		||||
	;;
 | 
			
		||||
    "User and password" )
 | 
			
		||||
	ydotool type --next-delay 500 $(rbw get --full "${SECRET}" | rg Username: | awk '{print $2}')
 | 
			
		||||
	ydotool key TAB
 | 
			
		||||
	ydotool type --next-delay 500 $(rbw get "${SECRET}")
 | 
			
		||||
	;;
 | 
			
		||||
    "QR-Code" )
 | 
			
		||||
	if [[ $SECRET =~ wifi$ ]]; then
 | 
			
		||||
	    # Produce a valid wifi QR-code
 | 
			
		||||
	    WIFISSID=$(pass get_user ${SECRET})
 | 
			
		||||
	    WIFIPASS=$(pass get_pass ${SECRET})
 | 
			
		||||
	    WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
 | 
			
		||||
	    qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
 | 
			
		||||
	else
 | 
			
		||||
	    # Only password
 | 
			
		||||
	    pass show -q1 ${SECRET}
 | 
			
		||||
	fi
 | 
			
		||||
	;;
 | 
			
		||||
    "OTP" )
 | 
			
		||||
	ydotool type --next-delay 300 $(rbw code ${SECRET})
 | 
			
		||||
	;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# wl-copy -o -s ${seat} ${PASSWD_PASS}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
list_windows() (
 | 
			
		||||
    wlrctl window list
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
window=$(list_windows | wofi -H 20% -id -p "select window..." | awk '{print $1}' | sed 's/://')
 | 
			
		||||
 | 
			
		||||
echo $window
 | 
			
		||||
 | 
			
		||||
wlrctl window focus $window
 | 
			
		||||
| 
						 | 
				
			
			@ -1,62 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
# Very basic interface for pass using wofi
 | 
			
		||||
 | 
			
		||||
# Get all password files and create an array
 | 
			
		||||
root=~/.password-store
 | 
			
		||||
CACHE=~/.local/tmp/pass_wofi
 | 
			
		||||
seat=seat0
 | 
			
		||||
 | 
			
		||||
list_passwords() {
 | 
			
		||||
    shopt -s nullglob globstar
 | 
			
		||||
	cd "${root}" || exit
 | 
			
		||||
	pw_list=(**/*.gpg)
 | 
			
		||||
	printf '%s\n' "${pw_list[@]%.gpg}" | sort -n
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
prompt='search for passwords...'
 | 
			
		||||
SECRET=$(list_passwords | wofi -i --prompt="${prompt}" --dmenu --cache-file ${CACHE})
 | 
			
		||||
 | 
			
		||||
# Ask whether pass, user or both are required
 | 
			
		||||
 | 
			
		||||
options=("Password" \
 | 
			
		||||
        "User" \
 | 
			
		||||
        "User and password" \
 | 
			
		||||
        "QR-Code" \
 | 
			
		||||
	"OTP")
 | 
			
		||||
 | 
			
		||||
option=$(printf '%s\n' "${options[@]%}" | wofi -i --dmenu --width 400 --lines 4 --prompt="..." --cache-file /dev/null)
 | 
			
		||||
 | 
			
		||||
echo $option
 | 
			
		||||
 | 
			
		||||
case ${option} in
 | 
			
		||||
    Password )
 | 
			
		||||
	echo "Test"
 | 
			
		||||
	wtype $(pass ${SECRET} | head -n 1)
 | 
			
		||||
	;;
 | 
			
		||||
    User )
 | 
			
		||||
	wtype $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	;;
 | 
			
		||||
    "User and password" )
 | 
			
		||||
	wtype $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
 | 
			
		||||
	wtype -k TAB
 | 
			
		||||
	wtype $(pass ${SECRET} | head -n 1)
 | 
			
		||||
	;;
 | 
			
		||||
    "QR-Code" )
 | 
			
		||||
	if [[ $SECRET =~ wifi$ ]]; then
 | 
			
		||||
	    # Produce a valid wifi QR-code
 | 
			
		||||
	    WIFISSID=$(pass get_user ${SECRET})
 | 
			
		||||
	    WIFIPASS=$(pass get_pass ${SECRET})
 | 
			
		||||
	    WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
 | 
			
		||||
	    qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
 | 
			
		||||
	else
 | 
			
		||||
	    # Only password
 | 
			
		||||
	    pass show -q1 ${SECRET}
 | 
			
		||||
	fi
 | 
			
		||||
	;;
 | 
			
		||||
    "OTP" )
 | 
			
		||||
	wtype $(pass otp ${SECRET})
 | 
			
		||||
	;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# wl-copy -o -s ${seat} ${PASSWD_PASS}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,51 +0,0 @@
 | 
			
		|||
#!/usr/bin/env bash
 | 
			
		||||
#
 | 
			
		||||
# Script name: dmqute
 | 
			
		||||
# Description: Search your qutebrowswer bookmarks and quickmarks.
 | 
			
		||||
# Dependencies: dmenu, qutebrowser
 | 
			
		||||
# GitLab: https://www.gitlab.com/dwt1/dmscripts
 | 
			
		||||
# License: https://www.gitlab.com/dwt1/dmscripts/LICENSE
 | 
			
		||||
# Contributors: Derek Taylor
 | 
			
		||||
 | 
			
		||||
# Defining location of bookmarks file
 | 
			
		||||
BMFILE="$HOME/.config/qutebrowser/bookmarks/urls"
 | 
			
		||||
 | 
			
		||||
# Defining location of quickmarks file
 | 
			
		||||
QMFILE="$HOME/.config/qutebrowser/quickmarks"
 | 
			
		||||
 | 
			
		||||
# Defining location of history database
 | 
			
		||||
HISTDB="$HOME/.local/share/qutebrowser/history.sqlite"
 | 
			
		||||
 | 
			
		||||
# A separator that will appear in between quickmarks, bookmarks and history urls.
 | 
			
		||||
SEPARATOR="----------"
 | 
			
		||||
 | 
			
		||||
# Read array of options to choose.
 | 
			
		||||
readarray -t bmarks < "$BMFILE"
 | 
			
		||||
readarray -t qmarks < "$QMFILE"
 | 
			
		||||
 | 
			
		||||
# Sort the bookmark, quickmark and history lists so that the url is the last field.
 | 
			
		||||
# We will awk print the last field later.
 | 
			
		||||
# History list is formed by grep'ing "http" from the history table.
 | 
			
		||||
bmlist=$(printf '%s\n' "${bmarks[@]}" | awk '{print $2" - "$1}')
 | 
			
		||||
qmlist=$(printf '%s\n' "${qmarks[@]}" | awk '{print "["$1"] - "$NF}' | sort)
 | 
			
		||||
SQL="SELECT h.title, h.url FROM history as h where url like 'http%';"
 | 
			
		||||
histlist=$(printf '%s\n' "$(sqlite3 "$HISTDB" "${SQL}")"  |  awk -F "|" '{print $1" - "$NF}')
 | 
			
		||||
 | 
			
		||||
# Piping the above lists into dmenu.
 | 
			
		||||
# We use "printf '%s\n'" to format the array one item to a line.
 | 
			
		||||
# The urls are listed quickmarks first, then the SEPARATOR, and then bookmarks.
 | 
			
		||||
choice=$(printf '%s\n' "$qmlist" "$SEPARATOR" "$bmlist" "$SEPARATOR" "$histlist" | wofi --columns=2 -p 'Qutebrowser open:' -dmenu) "$@" || exit
 | 
			
		||||
 | 
			
		||||
# What to do if the separator is chosen from the list.
 | 
			
		||||
# We simply launch qutebrowser without any url arguments.
 | 
			
		||||
# shellcheck disable=SC2154
 | 
			
		||||
if [ "$choice" == "$SEPARATOR" ]; then
 | 
			
		||||
    qutebrowser
 | 
			
		||||
# What to do when/if we choose a url to view.
 | 
			
		||||
elif [ "$choice" ]; then
 | 
			
		||||
  url=$(echo "${choice}" | awk '{print $NF}') || exit
 | 
			
		||||
  qutebrowser "$url"
 | 
			
		||||
# What to do if we just escape without choosing anything.
 | 
			
		||||
else
 | 
			
		||||
    echo "Program terminated." && exit 0
 | 
			
		||||
fi
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue