├── .gitignore ├── LICENSE.md ├── README.md ├── github-repos.sh ├── books-search └── books-search.sh └── web-search.sh /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Miroslav Vidović 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rofi-scripts 2 | 3 | ##### A collection of scripts for [rofi](https://davedavenport.github.io/rofi/) 4 | 5 | ## web-search.sh 6 | Search the web with rofi by selecting a website and providing a query. 7 | 8 | ## github-repos.sh 9 | Display all repositories connected with a GitHub user account in rofi and clone the selected repository. 10 | 11 | ## books-search.sh 12 | Search your book collection with rofi. 13 | 14 | ## License 15 | 16 | The MIT License (MIT) 17 | 18 | Copyright (c) 2018 Miroslav Vidović 19 | 20 | Permission is hereby granted, free of charge, to any person obtaining a copy 21 | of this software and associated documentation files (the "Software"), to deal 22 | in the Software without restriction, including without limitation the rights 23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | copies of the Software, and to permit persons to whom the Software is 25 | furnished to do so, subject to the following conditions: 26 | 27 | The above copyright notice and this permission notice shall be included in all 28 | copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | SOFTWARE. 37 | -------------------------------------------------------------------------------- /github-repos.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # ----------------------------------------------------------------------------- 4 | # Info: 5 | # author: Miroslav Vidovic 6 | # file: github-repos.sh 7 | # created: 04.04.2017.-09:18:34 8 | # revision: --- 9 | # version: 1.0 10 | # ----------------------------------------------------------------------------- 11 | # Requirements: 12 | # rofi, git 13 | # Description: 14 | # Display all repositories connected with a GitHub user account in rofi and 15 | # clone the selected repository. 16 | # Usage: 17 | # github-repos.sh 18 | # ----------------------------------------------------------------------------- 19 | # Script: 20 | 21 | # GitHub username 22 | USER="miroslavvidovic" 23 | 24 | # GitHub user account URL 25 | URL="https://github.com/$USER/" 26 | 27 | # Clone a repository into the current directory 28 | clone_repository(){ 29 | local repository=$1 30 | if [ -z "$repository" ]; then 31 | echo "ERROR: You need to enter the name of the repository you wish to clone." 32 | else 33 | git clone "$URL$repository" 34 | fi 35 | } 36 | 37 | # Get all the repositories for the user with curl and GitHub API and filter only 38 | # the repository name from the output with sed substitution 39 | all_my_repositories_short_name(){ 40 | curl -s "https://api.github.com/users/$USER/repos?per_page=1000" | grep -o 'git@[^"]*' |\ 41 | sed "s/git@github.com:$USER\///g" 42 | } 43 | 44 | # Rofi dmenu 45 | rofi_dmenu(){ 46 | rofi -dmenu -matching fuzzy -no-custom -p "Select a repository > "\ 47 | -location 0 -bg "#F8F8FF" -fg "#000000" -hlbg "#ECECEC" -hlfg "#0366d6" 48 | } 49 | 50 | main(){ 51 | repository=$(all_my_repositories_short_name | rofi_dmenu ) 52 | clone_repository "$repository" 53 | } 54 | 55 | main 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /books-search/books-search.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # ----------------------------------------------------------------------------- 4 | # Info: 5 | # author: Miroslav Vidovic 6 | # file: books-search.sh 7 | # created: 13.08.2017.-08:06:54 8 | # revision: --- 9 | # version: 1.0 10 | # ----------------------------------------------------------------------------- 11 | # Requirements: 12 | # rofi 13 | # Description: 14 | # Use rofi to search my books. 15 | # Usage: 16 | # books-search.sh 17 | # ----------------------------------------------------------------------------- 18 | # Script: 19 | 20 | # Books directory 21 | BOOKS_DIR=~/Books 22 | mkdir -p ~/Books 23 | 24 | # Save find result to F_ARRAY 25 | readarray -t F_ARRAY <<< "$(find "$BOOKS_DIR" -type f -name '*.pdf')" 26 | 27 | # Associative array for storing books 28 | # key => book name 29 | # value => absolute path to the file 30 | # BOOKS['filename']='path' 31 | declare -A BOOKS 32 | 33 | # Add elements to BOOKS array 34 | get_books() { 35 | 36 | # if [ ${#F_ARRAY[@]} != 0 ]; then 37 | if [[ ! -z ${F_ARRAY[@]} ]]; then 38 | for i in "${!F_ARRAY[@]}" 39 | do 40 | path=${F_ARRAY[$i]} 41 | file=$(basename "${F_ARRAY[$i]}") 42 | BOOKS+=(["$file"]="$path") 43 | done 44 | else 45 | echo "$BOOKS_DIR is empty!" 46 | echo "Please put some books in it." 47 | echo "Only .pdf files are accepted." 48 | exit 49 | fi 50 | 51 | 52 | } 53 | 54 | # List for rofi 55 | gen_list(){ 56 | for i in "${!BOOKS[@]}" 57 | do 58 | echo "$i" 59 | done 60 | } 61 | 62 | main() { 63 | get_books 64 | book=$( (gen_list) | rofi -dmenu -i -matching fuzzy -no-custom -location 0 -p "Book > " ) 65 | 66 | if [ -n "$book" ]; then 67 | xdg-open "${BOOKS[$book]}" 68 | fi 69 | } 70 | 71 | main 72 | 73 | exit 0 74 | -------------------------------------------------------------------------------- /web-search.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # ----------------------------------------------------------------------------- 4 | # Info: 5 | # author: Miroslav Vidovic 6 | # file: web-search.sh 7 | # created: 24.02.2017.-08:59:54 8 | # revision: --- 9 | # version: 1.0 10 | # ----------------------------------------------------------------------------- 11 | # Requirements: 12 | # rofi 13 | # Description: 14 | # Use rofi to search the web. 15 | # Usage: 16 | # web-search.sh 17 | # ----------------------------------------------------------------------------- 18 | # Script: 19 | 20 | declare -A URLS 21 | 22 | URLS=( 23 | ["google"]="https://www.google.com/search?q=" 24 | ["bing"]="https://www.bing.com/search?q=" 25 | ["yahoo"]="https://search.yahoo.com/search?p=" 26 | ["duckduckgo"]="https://www.duckduckgo.com/?q=" 27 | ["yandex"]="https://yandex.ru/yandsearch?text=" 28 | ["github"]="https://github.com/search?q=" 29 | ["goodreads"]="https://www.goodreads.com/search?q=" 30 | ["stackoverflow"]="http://stackoverflow.com/search?q=" 31 | ["symbolhound"]="http://symbolhound.com/?q=" 32 | ["searchcode"]="https://searchcode.com/?q=" 33 | ["openhub"]="https://www.openhub.net/p?ref=homepage&query=" 34 | ["superuser"]="http://superuser.com/search?q=" 35 | ["askubuntu"]="http://askubuntu.com/search?q=" 36 | ["imdb"]="http://www.imdb.com/find?ref_=nv_sr_fn&q=" 37 | ["rottentomatoes"]="https://www.rottentomatoes.com/search/?search=" 38 | ["piratebay"]="https://thepiratebay.org/search/" 39 | ["youtube"]="https://www.youtube.com/results?search_query=" 40 | ["vimawesome"]="http://vimawesome.com/?q=" 41 | ) 42 | 43 | # List for rofi 44 | gen_list() { 45 | for i in "${!URLS[@]}" 46 | do 47 | echo "$i" 48 | done 49 | } 50 | 51 | main() { 52 | # Pass the list to rofi 53 | platform=$( (gen_list) | rofi -dmenu -matching fuzzy -no-custom -location 0 -p "Search > " ) 54 | 55 | if [[ -n "$platform" ]]; then 56 | query=$( (echo ) | rofi -dmenu -matching fuzzy -location 0 -p "Query > " ) 57 | 58 | if [[ -n "$query" ]]; then 59 | url=${URLS[$platform]}$query 60 | xdg-open "$url" 61 | else 62 | exit 63 | fi 64 | 65 | else 66 | exit 67 | fi 68 | } 69 | 70 | main 71 | 72 | exit 0 73 | --------------------------------------------------------------------------------