mirror of
https://github.com/foo-dogsquared/dotfiles.git
synced 2025-01-30 22:57:54 +00:00
config: remove rofi and slop
They're more suitable for individual workflow configurations rather than to be sitting here in the personal-wide config.
This commit is contained in:
parent
f04a83fd83
commit
642e26cff5
154
rofi/modes/buku
154
rofi/modes/buku
@ -1,154 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is Burokufi, a Rofi frontend for Buku (https://github.com/jarun/Buku).
|
||||
# Mainly ~stolen~ inspired from the 'buku_run' script (https://github.com/carnager/buku_run/).
|
||||
# It is meant to be run as a modi (or script mode).
|
||||
# To get started, simply plop this script somewhere and run 'rofi -show buku -modi buku:<PATH>' and some of your personal options (e.g., custom keybindings, fullscreen, position).
|
||||
#
|
||||
# Dependencies (or at least the version by the time I made this):
|
||||
# * Buku v4.3
|
||||
# * GNU Bash v5.0.13
|
||||
# * Dunst v1.4.1 with libnotify
|
||||
# * Rofi v1.6.0
|
||||
# * jq v1.6
|
||||
|
||||
# The cache location.
|
||||
cachepath="${XDG_CACHE_HOME:-"$HOME/.cache"}/burokufi"
|
||||
mkdir -p $cachepath
|
||||
|
||||
# Tracking the last mode entered with a file.
|
||||
_name="Burokufi"
|
||||
modepath="$cachepath/recent-mode"
|
||||
debugpath="$cachepath/debug"
|
||||
|
||||
# Detects if it's run outside of Rofi script mode.
|
||||
if [ -z "$ROFI_OUTSIDE" ]
|
||||
then
|
||||
echo "This script is not supposed to run outside of Rofi script mode."
|
||||
echo "Usage: 'rofi -show <MODENAME> -modi <MODENAME>:$0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Getting the last mode state.
|
||||
mode=$(<"$modepath")
|
||||
|
||||
# Some first-time boot stuff.
|
||||
if [ "$ROFI_RETV" -eq 0 ]
|
||||
then
|
||||
mode='help'
|
||||
echo "$_name is here, boisengirls!" > "$debugpath"
|
||||
fi
|
||||
|
||||
# Defining some constants for convenience.
|
||||
message="'kb-custom-1' (Alt+1, by default) for bookmarks. 'kb-custom-2' (Alt+2) to view info on selected URL."
|
||||
|
||||
# Append to the logfile.
|
||||
function log() {
|
||||
echo "$@" >> "$debugpath"
|
||||
}
|
||||
|
||||
# Defining some functions also for convenience.
|
||||
# Overriding the Buku command with default actions.
|
||||
# It turns out when Buku is run within a non-TTY environment, it will print something like 'waiting for input' to the stdout.
|
||||
# So, there's an additional process to go through cutting some of it.
|
||||
# Here is the code block in question: https://github.com/jarun/buku/blob/a9fc0bd04297ef12349c0fe1d45bb3452e8c5425/buku#L4773
|
||||
# $@ - Its arguments.
|
||||
function buku() {
|
||||
command buku $@ | sed -e '1d'
|
||||
}
|
||||
|
||||
# This is the function that will print out the results.
|
||||
# It will always have an additional hidden URL info attached for convience.
|
||||
# You may freely edit this function to change the formatting of the URL list except for the ASCII delimiters at the end which is pretty important.
|
||||
# $1 - The JSON data of the Buku database.
|
||||
# The function will always assume the JSON is a top-level array with the Buku bookmarks as its items.
|
||||
# (See the command 'buku --print --json' for an example.)
|
||||
function print_to_rofi() {
|
||||
local buku_json="$1"
|
||||
[ "${#buku_json}" -eq 0 ] && return 1
|
||||
echo "$buku_json" | jq --raw-output '.[] | "<\(.index)> \(.uri)\\x00info\\x1f\(.uri)\\n"' | xargs --null echo -en
|
||||
}
|
||||
|
||||
# Print the help section. :)
|
||||
function print_help() {
|
||||
echo "Hey, listen!"
|
||||
echo "To open the selected URL, press 'kb-custom-2' (Alt+2 by default)."
|
||||
echo "To view details on the selected URL, press 'kb-custom-3' (Alt+3 by default)."
|
||||
echo "To go back to this help section, simply enter '??'."
|
||||
echo "To search for tags ('--stag'), prepend the query with '##'."
|
||||
echo "To search with a regex, prepend the query with '@@'."
|
||||
echo "To search with '--print', prepend the query with '..'."
|
||||
echo "To search for certain index ('--sany'), prepend the query with '>>'."
|
||||
}
|
||||
|
||||
# Here's the meat of the code.
|
||||
# This is the part that you might want to keep the attention.
|
||||
# It is simply a case statement for individual keybindings and their associated view.
|
||||
# You can view what other keybindings you can interact at https://github.com/davatorium/rofi/blob/next/doc/rofi-script.5.markdown.
|
||||
|
||||
# Keypresses and their events.
|
||||
case "$ROFI_RETV" in
|
||||
# 'kb-custom-1' (Alt+1, by default)
|
||||
10) mode='bookmark' ;;
|
||||
esac
|
||||
|
||||
# Typing '??' will go into help mode.
|
||||
if [ "$(expr match "$@" '??')" -ne 0 ]
|
||||
then
|
||||
mode='help'
|
||||
fi
|
||||
|
||||
log "$LINENO: mode before result is '$mode'"
|
||||
|
||||
# Detecting on what mode should be active.
|
||||
# For the most part, this should be the last part to be executed.
|
||||
case "$mode" in
|
||||
# The help mode where the help section is printed out.
|
||||
'help')
|
||||
prompt="Help"
|
||||
message="This is the help page, alright."
|
||||
print_help
|
||||
|
||||
# Once the help section is printed, automatically go into bookmark mode.
|
||||
mode='bookmark'
|
||||
;;
|
||||
|
||||
|
||||
# The bookmark mode.
|
||||
# This is also the default mode.
|
||||
'bookmark')
|
||||
prompt="Bookmarks"
|
||||
|
||||
if [ "$ROFI_RETV" -eq 11 ]
|
||||
then
|
||||
prompt="Info"
|
||||
active_url="$ROFI_INFO"
|
||||
buku --deep --sany "$active_url" --json | jq --raw-output '.[0] | keys[] as $k | "\($k): \(.[$k])\\x00nonselectable\\x1ftrue\\n"' | xargs --null echo -en
|
||||
elif [ "$(expr match "$@" '<[0-9]*>\s*')" -ne 0 ]
|
||||
then
|
||||
url=$(echo "$@" | tr -d "<[:digit:]*>[:space:]*")
|
||||
xdg-open "$url" && exit
|
||||
elif [[ "$@" == \#\#* ]]
|
||||
then
|
||||
print_to_rofi "$(buku --stag "${@#\#\#}" --json)" || echo -ne "No bookmark with the specified tag(s).\x00nonselectable\x1ftrue\n"
|
||||
elif [[ "$@" == \@\@* ]]
|
||||
then
|
||||
print_to_rofi "$(buku --sreg "${@#@@}" --json)" || echo -ne "No bookmark with the specified regex.\x00nonselectable\x1ftrue\n"
|
||||
elif [[ "$@" == \.\.* ]]
|
||||
then
|
||||
print_to_rofi "$(buku --print "${@#\.\.}" --json)" || echo -ne "No bookmark with the specified range.\x00nonselectable\x1ftrue\n"
|
||||
elif [[ "$@" == \>\>* ]]
|
||||
then
|
||||
print_to_rofi "$(buku --sany "${@#\>\>}" --json)" || echo -ne "No query result.\x00nonselectable\x1ftrue\n"
|
||||
else
|
||||
print_to_rofi "$(buku --print --json)"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
log "$LINENO: final mode before restart '$mode'"
|
||||
|
||||
# The message and prompt and whatnot.
|
||||
echo -en "\x00prompt\x1f$prompt\n"
|
||||
echo -en "\x00message\x1f$message\n"
|
||||
echo "$mode" > "$modepath"
|
@ -1,90 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is a Rofi script-mode script creating an interface for Recoll (https://www.lesbonscomptes.com/recoll/).
|
||||
# The selected path is then opened with its desktop launcher (e.g., xdg-open) and its location is copied on the clipboard.
|
||||
#
|
||||
# Dependencies:
|
||||
# * GNU Bash v5.0.13
|
||||
# * Recoll v1.27.0 with Xapian v1.4.15
|
||||
# * Dunst v1.4.1 with libnotify v0.7.9
|
||||
# * A desktop launcher (like xdg-open).
|
||||
# * A clipboard manager (like xclip).
|
||||
|
||||
# For getting started, you can view the documentation in https://github.com/davatorium/rofi/blob/next/doc/rofi-script.5.markdown.
|
||||
# As of 2020-06-06, the official version is not yet release and this script is developed for the 'next' branch which may have bugs present.
|
||||
|
||||
# Exit immediately if it's not run as a Rofi script.
|
||||
if [ -z "$ROFI_OUTSIDE" ]
|
||||
then
|
||||
echo "This script is not being run as a Rofi script."
|
||||
echo "Usage: 'rofi -show <MODENAME> -modi <MODENAME>:$0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Do stuff on first boot.
|
||||
if [ "$ROFI_RETV" = 0 ]
|
||||
then
|
||||
# Set the delimiter to '\x1'.
|
||||
# This is useful for creating entries with newlines (though, you have to manually set '-eh' option with >1).
|
||||
echo -en "\x00delim\x1f\\x1\n"
|
||||
|
||||
message="Search something..."
|
||||
fi
|
||||
|
||||
# Some constants to be used.
|
||||
# Btw, don't use primary selection of the location for copying it from xclip, it will freeze Rofi (and may cause this script to be empty which I found out the hard way).
|
||||
open_launcher_cmd="xdg-open"
|
||||
copy_to_clipboard_cmd="xclip -selection clipboard"
|
||||
prompt="Recoll"
|
||||
|
||||
function show_help() {
|
||||
echo -en "To search files, simply prepend the query with '##'.\x1"
|
||||
echo -en "Anything else should get you back reading this help section.\x1"
|
||||
echo -en "Happy searching, boisengirls! :)\x1"
|
||||
}
|
||||
|
||||
# By the time the user provided an input, this conditional will always fail.
|
||||
if [ -z "$@" ]
|
||||
then
|
||||
show_help
|
||||
else
|
||||
# If the entry is detected with the 'file://' URI protocol (which is returned from the Recoll query), it will open it and exit the script.
|
||||
if [[ "$@" == file://* ]]
|
||||
then
|
||||
coproc ( "$open_launcher_cmd" "$@" > /dev/null 2>&1 ) && notify-send "Opening file at $@..."
|
||||
exec 1>&-
|
||||
exit
|
||||
|
||||
# If the argument is detected as a query string (which is in format '##<QUERY>'), it will run the Recoll query.
|
||||
elif [[ "$@" == \#\#* ]]
|
||||
then
|
||||
recoll_query=${@#\#\#}
|
||||
|
||||
# The duration is in units of miliseconds.
|
||||
# This is a crude way but it is the simplest solution I could easily fit for now.
|
||||
duration_start=$(date +%s%N)
|
||||
readarray -d '\n' search_result <<< $(recoll -b -t -q "$recoll_query" 2>/dev/null)
|
||||
|
||||
# Since the Recoll command-line interface doesn't have indications whether the query has successfully delivered at least one item or not, counting the length of the resulting string is the next best thing.
|
||||
# If the string is only composed of one character, it most likely contain only a newline or something.
|
||||
if [ "${#search_result}" -gt 1 ]
|
||||
then
|
||||
# We're reducing it by one since there's a newline in the beginning in the result.
|
||||
query_count=$(echo "$search_result" | wc -l)
|
||||
awk '{print $0}' <<< "$search_result" | xargs -I% echo -en "%\x1"
|
||||
duration_end=$((($(date +%s%N) - $duration_start)/1000000))
|
||||
message="You've searched '$recoll_query' with ($query_count - 1) results completed in $duration_end ms."
|
||||
else
|
||||
message="Lol, no results."
|
||||
echo -en "I use Rofi btw.\x1"
|
||||
fi
|
||||
|
||||
# Otherwise, all entries that lead to nothing simply go back to the help section as promised. >:)
|
||||
else
|
||||
show_help
|
||||
fi
|
||||
fi
|
||||
|
||||
# Display the current message and the prompt, whatever that is.
|
||||
echo -en "\x00prompt\x1f$prompt\x1"
|
||||
echo -en "\x00message\x1f$message\x1"
|
@ -1,43 +0,0 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D desktop;
|
||||
uniform vec2 screenSize;
|
||||
uniform vec2 mouse;
|
||||
|
||||
varying vec2 uvCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
// adjustable parameters
|
||||
float circleSize = 28;
|
||||
float borderSize = 2;
|
||||
// The smaller this value is, the more intense the magnification!
|
||||
float magnifyNerf = 1.5;
|
||||
vec4 borderColor = vec4(0,0,0,1);
|
||||
bool crosshair = true;
|
||||
|
||||
// actual code
|
||||
vec2 mUV = vec2(mouse.x, -mouse.y)/screenSize + vec2(0,1);
|
||||
float du = distance(mUV,uvCoord);
|
||||
float dr = distance(mUV*screenSize,uvCoord*screenSize);
|
||||
vec4 color = vec4(0);
|
||||
if ( dr > circleSize+borderSize ) {
|
||||
color = texture2D( texture, uvCoord );
|
||||
} else if ( dr < circleSize ) {
|
||||
if ( crosshair && (distance(mUV.x, uvCoord.x)<1/screenSize.x || distance(mUV.y,uvCoord.y)<1/screenSize.y) ) {
|
||||
color = borderColor;
|
||||
} else {
|
||||
float t = 1-du;
|
||||
vec2 b = uvCoord;
|
||||
vec2 c = (mUV-uvCoord);
|
||||
vec2 upsideDown = c/magnifyNerf*t*t+b;
|
||||
|
||||
vec4 textureColor = texture2D( texture, upsideDown );
|
||||
color = mix( texture2D( desktop, vec2(upsideDown.x, -upsideDown.y) ), textureColor, textureColor.a );
|
||||
}
|
||||
} else if ( dr < circleSize+borderSize ) {
|
||||
color = borderColor;
|
||||
}
|
||||
gl_FragColor = color;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#version 120
|
||||
|
||||
attribute vec2 position;
|
||||
attribute vec2 uv;
|
||||
|
||||
varying vec2 uvCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvCoord = uv;
|
||||
gl_Position = vec4(position,0,1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user