From 7df2bd320d9085c26a2f7c9df49d6dff75bb3111 Mon Sep 17 00:00:00 2001 From: gotbletu Date: Thu, 23 Mar 2017 20:54:36 -0700 Subject: [PATCH] rofi scripts --- rofi-bangs.md | 52 +++++++++ rofi-scripts-collection/rofi-bangs.sh | 104 ++++++++++++++++++ rofi-scripts-collection/rofi-locate.sh | 19 ++++ .../rofi-surfraw-bookmarks.sh | 19 ++++ .../rofi-surfraw-websearch.sh | 20 ++++ 5 files changed, 214 insertions(+) create mode 100644 rofi-bangs.md create mode 100755 rofi-scripts-collection/rofi-bangs.sh create mode 100755 rofi-scripts-collection/rofi-locate.sh create mode 100755 rofi-scripts-collection/rofi-surfraw-bookmarks.sh create mode 100755 rofi-scripts-collection/rofi-surfraw-websearch.sh diff --git a/rofi-bangs.md b/rofi-bangs.md new file mode 100644 index 0000000..1b37f27 --- /dev/null +++ b/rofi-bangs.md @@ -0,0 +1,52 @@ +# Rofi-Bangs +a script to launch other rofi scripts + +* tutorial video: [Link](https://www.youtube.com/watch?v=kxJClZIXSnM) +* offical website: [Link](https://www.youtube.com/user/gotbletu) + +### install requirements + rofi + +### rofi matrix theme + vim ~/.Xresources && xrdb -load ~/.Xresources + + + ! ------------------------------------------------------------------------------ + ! ROFI Color theme + ! ------------------------------------------------------------------------------ + ! https://davedavenport.github.io/rofi/p11-Generator.html + rofi.color-enabled: true + rofi.color-window: #000000, #000000, #000000 + rofi.color-normal: #000000, #b3e774, #000000, #b3e774, #000000 + rofi.color-active: #000000, #b3e774, #000000, #b3e774, #000000 + rofi.color-urgent: #000000, #b3e774, #000000, #b3e774, #000000 + + +### rofi-bangs script and collections +Download at [rofi-scripts-collection](rofi-scripts-collection) + +### hotkey +bind **rofi-bangs.sh** to a hotkey + +### references +- Special Thanks to MoreChannelNoise https://www.youtube.com/user/MoreChannelNoise +- rofi-bangs: https://www.youtube.com/watch?v=kxJClZIXSnM +- rofi playlist: https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m +- surfraw playlist: https://www.youtube.com/playlist?list=PLqv94xWU9zZ2e-lDbmBpdASA6A6JF4Nyz + +### contact + + _ _ _ _ + __ _ ___ | |_| |__ | | ___| |_ _ _ + / _` |/ _ \| __| '_ \| |/ _ \ __| | | | + | (_| | (_) | |_| |_) | | __/ |_| |_| | + \__, |\___/ \__|_.__/|_|\___|\__|\__,_| + |___/ + +- http://www.youtube.com/user/gotbletu +- https://twitter.com/gotbletu +- https://plus.google.com/+gotbletu +- https://github.com/gotbletu +- gotbletu@gmail.com + + diff --git a/rofi-scripts-collection/rofi-bangs.sh b/rofi-scripts-collection/rofi-bangs.sh new file mode 100755 index 0000000..082355b --- /dev/null +++ b/rofi-scripts-collection/rofi-bangs.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# author: unknown +# sentby: MoreChannelNoise (https://www.youtube.com/user/MoreChannelNoise) +# editby: gotbletu (https://www.youtube.com/user/gotbletu) + +# demo: https://www.youtube.com/watch?v=kxJClZIXSnM +# info: this is a script to launch other rofi scripts, +# saves us the trouble of binding multiple hotkeys for each script, +# when we can just use one hotkey for everything. + +declare -A LABELS +declare -A COMMANDS + +### +# List of defined 'bangs' + +# launch programs +COMMANDS["apps"]="rofi -combi-modi window,drun -show combi" +LABELS["apps"]="" + +# open bookmarks +COMMANDS["bookmarks"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-bookmarks.sh" +LABELS["bookmarks"]="" + +# search local files +COMMANDS["locate"]="~/.scripts/rofi-scripts-collection/rofi-locate.sh" +LABELS["locate"]="" + +# open custom web searches +COMMANDS["websearch"]="~/.scripts/rofi-scripts-collection/rofi-surfraw-websearch.sh" +LABELS["websearch"]="" + +# show clipboard history +# source: https://bitbucket.org/pandozer/rofi-clipboard-manager/overview +# COMMANDS["clipboard"]='rofi -modi "clipboard:~/.bin/rofi-clipboard-manager/mclip.py menu" -show clipboard && ~/.bin/rofi-clipboard-manager/mclip.py paste' +# LABELS["clipboard"]="" + +# references -------------------------- +# COMMANDS[";sr2"]="chromium 'wikipedia.org/search-redirect.php?search=\" \${input}\"" +# LABELS[";sr2"]="" + +# COMMANDS[";piratebay"]="chromium --disk-cache-dir=/tmp/cache http://thepiratebay.org/search/\" \${input}\"" +# LABELS[";piratebay"]="" + +# COMMANDS[".bin"]="spacefm -r '/home/dka/bin'" +# LABELS[".bin"]=".bin" + +# COMMANDS["#screenshot"]='/home/dka/bin/screenshot-scripts/myscreenshot.sh' +# LABELS["#screenshot"]="screenshot" + +################################################################################ +# do not edit below +################################################################################ +## +# Generate menu +## +function print_menu() +{ + for key in ${!LABELS[@]} + do + echo "$key ${LABELS}" + # echo "$key ${LABELS[$key]}" + # my top version just shows the first field in labels row, not two words side by side + done +} +## +# Show rofi. +## +function start() +{ + # print_menu | rofi -dmenu -p "?=>" + print_menu | rofi -dmenu -mesg ">>> launch your collection of rofi scripts" -i -p "rofi-bangs: " + +} + + +# Run it +value="$(start)" + +# Split input. +# grab upto first space. +choice=${value%%\ *} +# graph remainder, minus space. +input=${value:$((${#choice}+1))} + +## +# Cancelled? bail out +## +if test -z ${choice} +then + exit +fi + +# check if choice exists +if test ${COMMANDS[$choice]+isset} +then + # Execute the choice + eval echo "Executing: ${COMMANDS[$choice]}" + eval ${COMMANDS[$choice]} +else + eval $choice | rofi + # prefer my above so I can use this same script to also launch apps like geany or leafpad etc (DK) + # echo "Unknown command: ${choice}" | rofi -dmenu -p "error" +fi diff --git a/rofi-scripts-collection/rofi-locate.sh b/rofi-scripts-collection/rofi-locate.sh new file mode 100755 index 0000000..3bec365 --- /dev/null +++ b/rofi-scripts-collection/rofi-locate.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# _ _ _ _ +# __ _ ___ | |_| |__ | | ___| |_ _ _ +# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | +#| (_| | (_) | |_| |_) | | __/ |_| |_| | +# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| +# |___/ +# https://www.youtube.com/user/gotbletu +# https://twitter.com/gotbletu +# https://plus.google.com/+gotbletu +# https://github.com/gotbletu +# gotbleu@gmail.com + +# info: rofi-locate is a script to search local files and folders on your computer using the locate command and the updatedb database +# requirements: rofi mlocate +# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m + +xdg-open "$(locate home media | rofi -threads 0 -width 100 -dmenu -i -p "locate:")" + diff --git a/rofi-scripts-collection/rofi-surfraw-bookmarks.sh b/rofi-scripts-collection/rofi-surfraw-bookmarks.sh new file mode 100755 index 0000000..2ce3df0 --- /dev/null +++ b/rofi-scripts-collection/rofi-surfraw-bookmarks.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# _ _ _ _ +# __ _ ___ | |_| |__ | | ___| |_ _ _ +# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | +#| (_| | (_) | |_| |_) | | __/ |_| |_| | +# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| +# |___/ +# https://www.youtube.com/user/gotbletu +# https://twitter.com/gotbletu +# https://plus.google.com/+gotbletu +# https://github.com/gotbletu +# gotbleu@gmail.com + +# info: rofi-surfraw-bookmarks is a script to open your saved surfraw bookmarks with the rofi launcher +# requirements: rofi surfraw +# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m +# surfraw https://www.youtube.com/playlist?list=PLqv94xWU9zZ2e-lDbmBpdASA6A6JF4Nyz + +surfraw -browser=$BROWSER "$(cat ~/.config/surfraw/bookmarks | sed '/^$/d' | sed '/^#/d' | sed '/^\//d' | sort -n | rofi -dmenu -mesg ">>> Edit to add new bookmarks at ~/.config/surfraw/bookmarks" -i -p "rofi-surfraw-bookmarks: ")" diff --git a/rofi-scripts-collection/rofi-surfraw-websearch.sh b/rofi-scripts-collection/rofi-surfraw-websearch.sh new file mode 100755 index 0000000..60677a0 --- /dev/null +++ b/rofi-scripts-collection/rofi-surfraw-websearch.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# _ _ _ _ +# __ _ ___ | |_| |__ | | ___| |_ _ _ +# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | +#| (_| | (_) | |_| |_) | | __/ |_| |_| | +# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| +# |___/ +# https://www.youtube.com/user/gotbletu +# https://twitter.com/gotbletu +# https://plus.google.com/+gotbletu +# https://github.com/gotbletu +# gotbleu@gmail.com + +# info: rofi-surfraw-websearch is a script to do internet searches from different websites, all from the rofi launcher +# requirements: rofi surfraw +# playlist: rofi https://www.youtube.com/playlist?list=PLqv94xWU9zZ0LVP1SEFQsLEYjZC_SUB3m +# surfraw https://www.youtube.com/playlist?list=PLqv94xWU9zZ2e-lDbmBpdASA6A6JF4Nyz + +surfraw -browser=$BROWSER $(sr -elvi | awk -F'-' '{print $1}' | sed '/:/d' | awk '{$1=$1};1' | rofi -kb-row-select "Tab" -kb-row-tab "Control+space" -dmenu -mesg ">>> Tab = Autocomplete" -i -p "rofi-surfraw-websearch: ") +