README and rofi menu

This commit is contained in:
Neptune 2020-10-11 12:10:22 +02:00
parent ce99d2401f
commit cd8efa812d
8 changed files with 201 additions and 167 deletions

View file

@ -35,19 +35,73 @@ $ ./setup.sh music
== Music == Music
image:./.pictures/neofetch-music-cover.png[width=50%] image:./.pictures/neofetch-music-cover.png[width=100%]
Album cover is generated with link:./music/.config/ncmpcpp/art.sh[`~/.config/ncmpcpp/art.sh`], the cover pictured is searched and `ffmpeg` is used to generate the thumbnail with round borders and cropped to 300px. Album cover is generated with link:./music/.config/ncmpcpp/art.sh[`~/.config/ncmpcpp/art.sh`], the cover pictured is searched and `ffmpeg` is used to generate the thumbnail with round borders and cropped to 300px.
The cover is displayed using Kitty icat with link:./music/.config/ncmpcpp/kitty.sh[`~/.config/ncmpcpp/kitty.sh`]. The cover is displayed using Kitty icat with link:./music/.config/ncmpcpp/kitty.sh[`~/.config/ncmpcpp/kitty.sh`].
The alias `music` used to open the music player make just use of background processes to have the cover preview and ncmpcpp on the same window.
[source,shell]
----
abbr music 'mpc -q play; ~/.config/ncmpcpp/art.sh; sleep 1; ~/.config/ncmpcpp/kitty.sh &; ncmpcpp'
----
== Browse files == Browse files
image:./.pictures/important-work-manga.png[width=50%] image:./.pictures/important-work-manga.png[width=100%]
== Qt theme === Vifm
image:./.pictures/files-find-a-bird.png[width=50%] Vifm has image preview activated using the custom script link:./terminal/.config/vifm/scripts/preview[`~/.config/vifm/scripts/preview`], can be previewed pictures, video files, music spectrograms, epub and pdfs.
* Set wallpaper and update color scheme with kbd:[w]
* Extract archives with kbd:[x]
=== Fzf
The terminal has integrated fzf support. A preview script is available at link:./terminal/.config/kitty/preview[`~/.config/kitty/preview`]
* Find files with kbd:[Ctrl + t]
* Command history with kbd:[Ctrl + r]
=== Imv
Imv image viewer has been tuned to work with link:https://github.com/Liupold/pidswallow[window swallowing] and to be a very good manga reader.
* Running the `manga` command defined at link:./terminal/.config/fish/functions/manga[`~/.config/fish/functions/manga`] will open recursively all files in the folder sorted by name. It will also open the last visited page for it is tracking reading progress.
* The window title is updated with `[<current-page>/<total-page>]: <folder-name>` status.
* Next page start at the top (initial_pan = 0 0)
* Change scaling mode with kbd:[s]
* Tag a picture with kbd:[m], tags are available under `~/tags`
==== How it works
Imv is run with window properties changed using this black magic spell.
[source,shell]
----
alias imv 'imv -c "exec _wid=\$(xdo id);xprop -f WM_CLIENT_MACHINE 8s -set WM_CLIENT_MACHINE \$(hostname) -id \$_wid;xprop -f _NET_WM_PID 32c -set _NET_WM_PID \$imv_pid -id \$_wid;pidswallow -gt \$_wid"'
----
Reading progress is stored under `~/.cache/imv/` in the base64 hash of the directory path.
The imv config link:./terminal/.config/imv/config[`~/.config/imv/config`] has the following line that update the window title and store reading progress.
[source,ini]
----
title_text = $(xdotool getactivewindow set_window --name "[ $imv_current_index / $imv_file_count ] : $(echo "${PWD##*/}")"; echo "$imv_current_index" > ~/.cache/imv/$(echo "$PWD" | base64) )
----
== Launch application == Launch application
image:./.pictures/rofi-when-they-cry.png[width=50%] image:./.pictures/rofi-when-they-cry.png[width=100%]
Rofi is the application launcher and is called with kbd:[Ctrl + Space].
Background color is updated with the theme using link:https://github.com/dylanaraps/pywal[`pywal`] templates.
== Qt theme and global menu
image:./.pictures/files-find-a-bird.png[width=100%]
Qt applications use Kvantum with link:https://store.kde.org/p/1365482/[Inverse-dark theme].
Global menu is set with `xfce4-panel` that was just moved on top of polybar.

View file

@ -8,7 +8,7 @@ super + Return
# program launcher # program launcher
super + space super + space
rofi -show drun \ rofi -show drun -fullscreen \
--terminal kitty --terminal kitty
# make sxhkd reload its configuration files: # make sxhkd reload its configuration files:
@ -146,7 +146,7 @@ Print
maim -ui (xdotool getactivewindow) ~/Pictures/Screenshot_(date +"%Y%m%d")_(date +"%H%M%S").png maim -ui (xdotool getactivewindow) ~/Pictures/Screenshot_(date +"%Y%m%d")_(date +"%H%M%S").png
shift + Print shift + Print
sleep 3; maim -ux :0.0 ~/Pictures/Screenshot_(date +"%Y%m%d")_(date +"%H%M%S").png maim -ux :0.0 ~/Pictures/Screenshot_(date +"%Y%m%d")_(date +"%H%M%S").png
super + shift + Print super + shift + Print
maim -us ~/Pictures/Screenshot_(date +"%Y%m%d")_(date +"%H%M%S").png maim -us ~/Pictures/Screenshot_(date +"%Y%m%d")_(date +"%H%M%S").png

View file

@ -1,4 +1,4 @@
:toc: left //:toc: left
:doctype: book :doctype: book
// Settings: // Settings:
:experimental: :experimental:

View file

@ -1,124 +1,127 @@
/* Based on https://github.com/adi1090x/rofi/blob/master/launchers-git/blurry_full.rasi */
configuration { configuration {
modi: "window,run,drun"; font: "Iosevka Nerd Font 11";
theme: "clean"; show-icons: true;
show-icons: true; icon-theme: "Papirus Dark";
font: "Hack 11"; threads: 0;
scroll-method: 0;
disable-history: false;
fullscreen: false;
hide-scrollbar: true;
sidebar-mode: false;
display-drun: " ";
} }
/* @import "colors.rasi" */
@import "~/.cache/wal/colors.rasi" @import "~/.cache/wal/colors.rasi"
#window { window {
width: 100%; transparency: "real";
height: 100%; background-color: @background;
background-color: rgba(255, 255, 255, 0.1); text-color: @foreground;
padding: 90px 120px; height: 100%;
width: 100%;
location: northwest;
anchor: northwest;
x-offset: 0;
y-offset: 0;
} }
#mainbox { prompt {
border: 0; enabled: true;
border-radius: 15; background-color: @background;
padding: 20; text-color: @foreground;
background-color: @background;
} }
#textbox {
text-color: @foreground; inputbar {
background-color: @background-alt;
text-color: @foreground;
expand: false;
border-radius: 6px;
margin: 0px 430px 0px 430px;
padding: 10px 10px 10px 10px;
position: north;
} }
#listview {
padding: 20px; entry {
columns: 5; background-color: @background;
spacing: 4px; text-color: @foreground;
cycle: false; placeholder-color: @foreground;
dynamic: true; expand: true;
layout: vertical; horizontal-align: 0.01;
background-color: transparent; blink: true;
}
case-indicator {
background-color: @background;
text-color: @foreground;
spacing: 0;
}
listview {
background-color: @background;
padding: 20px;
columns: 3;
spacing: 4px;
cycle: false;
dynamic: true;
layout: vertical;
}
mainbox {
background-color: @background-color;
children: [ inputbar, listview ];
spacing: 25px;
padding: 70px 135px 55px 135px;
} }
element { element {
margin: 11px; background-color: @background;
padding: 14px; text-color: @foreground;
border-radius: 5px; orientation: vertical;
orientation: vertical; border-radius: 9px;
padding: 20px 0px 20px 0px;
} }
element-icon { element-icon {
size: 80px; size: 128px;
margin: 0 10px 0 0; border: 0px;
} }
element-text { element-text {
horizontal-align: 0.5; expand: true;
vertical-align: 0.5; horizontal-align: 0.5;
vertical-align: 0.5;
margin: 5px 10px 0px 10px;
} }
#element.normal.normal { element normal.urgent,
background-color: transparent; element alternate.urgent {
text-color: @foreground; background-color: @urgent;
text-color: @foreground;
border-radius: 9px;
} }
#element.selected.normal { element normal.active,
background-color: @selected-background; element alternate.active {
text-color: @selected-foreground; background-color: @background-alt;
border-color: #d07ef2; text-color: @foreground;
} }
#element.alternate.normal { element selected {
background-color: transparent; background-color: @background-alt;
text-color: @foreground; text-color: @foreground-selected;
} }
#mode-switcher { element selected.urgent {
border: 0px 0px 0px ; background-color: @urgent-selected;
border-color: @separatorcolor; text-color: @foreground;
} }
#button { element selected.active {
spacing: 0; background-color: @background-alt;
text-color: @foreground; color: @foreground-selected;
}
#button.selected {
background-color: @selected-background;
text-color: @selected-foreground;
}
#inputbar {
spacing: 0;
text-color: @selected-foreground;
padding: 10px;
background-color: @selected-background;
/*rgba(0,0,0,0.5);*/
border-radius: 10px;
}
#case-indicator {
spacing: 0;
text-color: @selected-foreground;
background-color: rgba(0,0,0,0);
}
#entry {
spacing: 0;
text-color: @selected-foreground;
background-color: rgba(0,0,0,0);
}
#prompt {
spacing: 0;
text-color: @selected-foreground;
background-color: rgba(0,0,0,0);
}
#textbox-prompt-colon {
expand: false;
str: ":";
margin: 0px 0.3em 0em 0em ;
text-color: @selected-foreground;
background-color: rgba(0,0,0,0);
}
#inputbar {
children: [prompt,textbox-prompt-colon,entry,case-indicator];
} }

View file

@ -32,9 +32,9 @@ rounded_cover() {
fallback_find_cover() { fallback_find_cover() {
album=$(dirname "$file") album=$(dirname "$file")
album_cover="$(find "$album" -type d -exec find {} -maxdepth 1 -type f -iregex ".*\(covers?\|folders?\|artworks?\|fronts?\|scans?\).*[.]\(jpe?g\|png\|gif\|bmp\)" \;)" album_cover="$(find "$album" -type d -exec find {} -maxdepth 1 -type f -iregex ".*\(covers?\|folders?\|artworks?\|fronts?\|scans?\).*[.]\(jpe?g\|png\|gif\|bmp\)" \;)"
[ ! -f "$album_cover" ] && album_cover="$(find "$album" -type d -exec find {} -maxdepth 1 -type f -iregex ".*[.]\(jpe?g\|png\|gif\|bmp\)" \;)" [ -z "$album_cover" ] && album_cover="$(find "$album" -type d -exec find {} -maxdepth 1 -type f -iregex ".*[.]\(jpe?g\|png\|gif\|bmp\)" \;)"
[ ! -f "$album_cover" ] && album_cover="$(find "${album%/*}" -type d -exec find {} -maxdepth 1 -type f -iregex ".*\(covers?\|folders?\|artworks?\|fronts?\|scans?\|booklets?\).*[.]\(jpe?g\|png\|gif\|bmp\)" \;)" [ -z "$album_cover" ] && album_cover="$(find "${album%/*}" -type d -exec find {} -maxdepth 1 -type f -iregex ".*\(covers?\|folders?\|artworks?\|fronts?\|scans?\|booklets?\).*[.]\(jpe?g\|png\|gif\|bmp\)" \;)"
album_cover="$(echo -n "$album_cover" | grep -iv 'back' | head -n1)" album_cover="$(echo -n "$album_cover" | grep -iv '\(back\|cd\)\.' | head -n1)"
} }
main() { main() {

View file

@ -70,4 +70,4 @@ t = slideshow +1
<Shift+T> = slideshow -1 <Shift+T> = slideshow -1
# Use dmenu as a prompt for tagging the current image # Use dmenu as a prompt for tagging the current image
m = exec echo "$imv_current_file" >> ~/tags/$(ls ~/tags | rofi -dmenu -p " tags: ") m = exec echo "$imv_current_file" >> ~/tags/$(ls ~/tags | rofi -dmenu -fullscreen -p " tags: ")

View file

@ -1,91 +1,65 @@
#!/usr/bin/env bash #!/usr/bin/env sh
X="2" X="2"
Y="2" Y="2"
WIDTH="$FZF_PREVIEW_COLUMNS" WIDTH="$FZF_PREVIEW_COLUMNS"
HEIGHT="$FZF_PREVIEW_LINES" HEIGHT="$FZF_PREVIEW_LINES"
TMP="/tmp/fzf-preview$PWD/" TMP="/tmp/fzf-preview"
CACHEFILE="$TMP/$(echo "$1" | base64).png"
# Create temporary working directory if the directory structure doesn't exist maketemp() {
function maketemp() { [ ! -d "$TMP" ] && mkdir -p "$TMP"
if [ ! -d "$(dirname "$TMP$1")" ]; then
mkdir -p "$(dirname "$TMP$1")"
fi
} }
function fileclean() { previewclear() {
if [ -f "$TMP$1.png" ]; then
rm -f "$TMP$1.png"
elif [ -d "$TMP$1/" ]; then
rm -rf "$TMP$1/"
fi
}
function previewclear() {
kitty +kitten icat --transfer-mode=file --silent --clear kitty +kitten icat --transfer-mode=file --silent --clear
} }
function text() { text() {
bat --pager=never --wrap never --style="changes" --color="always" "$1" -p bat --pager=never --wrap never --style="changes" --color="always" "$1" -p
} }
function torrent() { torrent() {
aria2c --show-files "$1" aria2c --show-files "$1"
} }
function archive() { archive() {
atool -l -q "$1" | tail -n +2 | awk -F' ' '{print $NF}' atool -l -q "$1" | tail -n +2 | awk -F' ' '{print $NF}'
} }
function draw() { draw() {
kitty +kitten icat --transfer-mode=file --silent --align=left --place=${WIDTH}x${HEIGHT}@${X}x${Y} --z-index=-1 "$1" kitty +kitten icat --transfer-mode=file --silent --align=left --place=${WIDTH}x${HEIGHT}@${X}x${Y} --z-index=-1 "$1"
} }
function image() { image() {
draw "$1" draw "$1"
} }
function audio() { # https://ffmpeg.org/ffmpeg-filters.html#showspectrum-1
maketemp "$1" audio() {
if [ ! -f "$TMP$1.png" ]; then [ ! -f "$CACHEFILE" ] && ffmpeg -loglevel 0 -y -i "$1" -lavfi "showspectrumpic=s=hd480:legend=0:gain=5:color=intensity" "$CACHEFILE"
# https://ffmpeg.org/ffmpeg-filters.html#showspectrum-1 draw "$CACHEFILE"
ffmpeg -loglevel 0 -y -i "$1" -lavfi "showspectrumpic=s=hd480:legend=0:gain=5:color=intensity" "$TMP$1.png"
fi
draw "$TMP$1.png"
} }
function video() { video() {
maketemp "$1" [ ! -f "$CACHEFILE" ] && ffmpegthumbnailer -i "$1" -o "$CACHEFILE" -s 1024 -q 10
if [ ! -f "$TMP$1.png" ]; then draw "$CACHEFILE"
ffmpegthumbnailer -i "$1" -o "$TMP$1.png" -s 1024 -q 10
fi
draw "$TMP$1.png"
} }
function pdf() { pdf() {
maketemp "$1" [ ! -f "$CACHEFILE.png" ] && pdftoppm -png -singlefile "$1" "$CACHEFILE" -scale-to 1024
if [ ! -f "$TMP$1.png" ]; then draw "$CACHEFILE.png"
pdftoppm -png -singlefile "$1" "$TMP$1" -scale-to 1024
fi
draw "$TMP$1.png"
} }
function epub() { epub() {
maketemp "$1" [ ! -f "$CACHEFILE" ] && epub-thumbnailer "$1" "$CACHEFILE" 1024
if [ ! -f "$TMP$1.png" ]; then draw "$CACHEFILE"
epub-thumbnailer "$1" "$TMP$1.png" 1024
fi
draw "$TMP$1.png"
} }
function main() { main() {
mimetype=$(file -b --mime-type "$1")
previewclear previewclear
maketemp
if [ $mimetype != "inode/directory" ]; then mimetype=$(file -b --mime-type "$1")
fileclean "$1"
fi
case $mimetype in case $mimetype in
application/epub*) application/epub*)
@ -94,7 +68,7 @@ function main() {
pdf "$1";; pdf "$1";;
application/x-bittorrent) application/x-bittorrent)
torrent "$1";; torrent "$1";;
application/zip | application/x-tar | *rar ) application/zip | application/x-tar | *rar | application/gzip )
archive "$1";; archive "$1";;
audio/*) audio/*)
audio "$1";; audio "$1";;
@ -105,8 +79,9 @@ function main() {
video/*) video/*)
video "$1";; video "$1";;
inode/directory) inode/directory)
exa --color always "$1";; [ -z "${1##*/..*}" ] && echo || exa -Fa --color always "$1";;
*);; *)
text "$1";;
esac esac
} }

View file

@ -1,8 +1,10 @@
* {{ * {{
foreground: rgba(196, 203, 212, 100%); background: #00000000;
selected-foreground: rgba(255, 255, 255, 100%); background-color: #00000066;
background-entry: #00000033;
background: {background}C2; background-alt: {color1}80;
background-solid: {background}; foreground: #f2f2f2EE;
selected-background: rgba(0, 0, 0, 40%); foreground-selected: #ffffffFF;
urgent: #E91E6366;
urgent-selected: #E91E6377;
}} }}