Get to your ebooks quickly
2018-11-12
393 words
2 mins read
To begin with, here is screenshot of how it would look like finally:
We are using “rofi” here to show the menu. So, lets first install that
cat <<EOF >/etc/yum.repos.d/_copr_yaroslav-i3desktop.repo [yaroslav-i3desktop] name=Copr repo for i3desktop owned by yaroslav baseurl=https://copr-be.cloud.fedoraproject.org/results/yaroslav/i3desktop/fedora-$releasever-$basearch/ type=rpm-md skip_if_unavailable=True gpgcheck=1 gpgkey=https://copr-be.cloud.fedoraproject.org/results/yaroslav/i3desktop/pubkey.gpg repo_gpgcheck=0 enabled=1 EOF yum install rofi
#!/usr/bin/env bash # # wget 'https://raw.githubusercontent.com/miroslavvidovic/rofi-scripts/master/books-search/books-search.sh'—————————————————————————–
Info:
author: Miroslav Vidovic
file: books-search.sh
created: 13.08.2017.-08:06:54
revision: —
version: 1.0
—————————————————————————–
Requirements:
rofi
Description:
Use rofi to search my books.
Usage:
books-search.sh
—————————————————————————–
Script:
Modified by Amit Agarwal
Books directory
BOOKS_DIR=/usr/share/texlive/texmf-dist/doc/
Save find result to F_ARRAY
readarray -t F_ARRAY <<< “$(find “$BOOKS_DIR” -type f -name ‘*.pdf’)”
Associative array for storing books
key => book name
value => absolute path to the file
BOOKS[‘filename’]=‘path’
declare -A BOOKS
Add elements to BOOKS array
get_books() { for i in “${!F_ARRAY[@]}” do path=${F_ARRAY[$i]} file=$(basename “${F_ARRAY[$i]}”) BOOKS+=(["$file"]="$path") done }
List for rofi
gen_list(){ for i in “${!BOOKS[@]}” do echo “$i” done }
main() { get_books
book=$( (gen_list) | rofi -dmenu -lines 10 -width 100 -i -matching fuzzy -only-match -location 0 -fake-transparency -p “Book > " ) book=$( (gen_list) | rofi -dmenu -i -matching fuzzy -only-match -p “Book > " ) xdg-open “${BOOKS[$book]}” }
main exit 0
cat <<EOF >~/.Xresources rofi.color-enabled: true rofi.opacity: 50 rofi.width: 100 rofi.lines: 10 rofi.columns: 4 rofi.font: System San Francisco Display 8 rofi.color-normal: #fdf6e3,#002b36,#eee8d5,#586e75,#eee8d5 rofi.color-urgent: #fdf6e3,#dc322f,#eee8d5,#dc322f,#fdf6e3 rofi.color-active: #fdf6e3,#268bd2,#eee8d5,#268bd2,#fdf6e3 rofi.color-window: #fdf6e3,#002b36 rofi.yoffset: 0 rofi.xoffset: 0 rofi.fixed-num-lines: false rofi.terminal: rofi-sensible-terminal rofi.ssh-client: ssh rofi.ssh-command: {terminal} -e {ssh-client} {host} rofi.run-command: {cmd} rofi.run-list-command: rofi.run-shell-command: {terminal} -e {cmd} rofi.window-command: xkill -id {window} rofi.disable-history: false rofi.levenshtein-sort: false rofi.case-sensitive: false rofi.cycle: true rofi.sidebar-mode: false rofi.auto-select: false rofi.parse-hosts: true rofi.parse-known-hosts: true rofi.combi-modi: window,run rofi.fuzzy: true rofi.glob: false rofi.regex: false rofi.tokenize: true rofi.m: -1 rofi.line-margin: 2 rofi.filter: rofi.separator-style: dash rofi.hide-scrollbar: false rofi.fullscreen: false rofi.fake-transparency: true rofi.dpi: -1 rofi.threads: 1 rofi.scrollbar-width: 8 rofi.scroll-method: 0 rofi.fake-background: screenshot rofi.display-ssh: rofi.display-run: rofi.display-drun: rofi.display-combi: EOFxrdb -merge ~/.Xresources
Related Articles:
- 2015/10/15 Get count of lines in scripts (shell)
- 2016/01/05 image ordering by Original Date Time using bash script
- 2014/05/05 Some nice linux tutorials
- 2011/05/16 Unix shell script for removing duplicate files
- 2011/01/25 shopt causes bash completion to stop working.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.