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
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.
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
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
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
super + space
rofi -show drun \
rofi -show drun -fullscreen \
--terminal kitty
# 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
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
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
// Settings:
:experimental:

View file

@ -1,124 +1,127 @@
/* Based on https://github.com/adi1090x/rofi/blob/master/launchers-git/blurry_full.rasi */
configuration {
modi: "window,run,drun";
theme: "clean";
show-icons: true;
font: "Hack 11";
font: "Iosevka Nerd Font 11";
show-icons: true;
icon-theme: "Papirus Dark";
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"
#window {
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.1);
padding: 90px 120px;
window {
transparency: "real";
background-color: @background;
text-color: @foreground;
height: 100%;
width: 100%;
location: northwest;
anchor: northwest;
x-offset: 0;
y-offset: 0;
}
#mainbox {
border: 0;
border-radius: 15;
padding: 20;
background-color: @background;
prompt {
enabled: true;
background-color: @background;
text-color: @foreground;
}
#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;
columns: 5;
spacing: 4px;
cycle: false;
dynamic: true;
layout: vertical;
background-color: transparent;
entry {
background-color: @background;
text-color: @foreground;
placeholder-color: @foreground;
expand: true;
horizontal-align: 0.01;
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 {
margin: 11px;
padding: 14px;
border-radius: 5px;
orientation: vertical;
background-color: @background;
text-color: @foreground;
orientation: vertical;
border-radius: 9px;
padding: 20px 0px 20px 0px;
}
element-icon {
size: 80px;
margin: 0 10px 0 0;
size: 128px;
border: 0px;
}
element-text {
horizontal-align: 0.5;
vertical-align: 0.5;
expand: true;
horizontal-align: 0.5;
vertical-align: 0.5;
margin: 5px 10px 0px 10px;
}
#element.normal.normal {
background-color: transparent;
text-color: @foreground;
element normal.urgent,
element alternate.urgent {
background-color: @urgent;
text-color: @foreground;
border-radius: 9px;
}
#element.selected.normal {
background-color: @selected-background;
text-color: @selected-foreground;
border-color: #d07ef2;
element normal.active,
element alternate.active {
background-color: @background-alt;
text-color: @foreground;
}
#element.alternate.normal {
background-color: transparent;
text-color: @foreground;
element selected {
background-color: @background-alt;
text-color: @foreground-selected;
}
#mode-switcher {
border: 0px 0px 0px ;
border-color: @separatorcolor;
element selected.urgent {
background-color: @urgent-selected;
text-color: @foreground;
}
#button {
spacing: 0;
text-color: @foreground;
}
#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];
element selected.active {
background-color: @background-alt;
color: @foreground-selected;
}

View file

@ -32,9 +32,9 @@ rounded_cover() {
fallback_find_cover() {
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\)" \;)"
[ ! -f "$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\)" \;)"
album_cover="$(echo -n "$album_cover" | grep -iv 'back' | head -n1)"
[ -z "$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 ".*\(covers?\|folders?\|artworks?\|fronts?\|scans?\|booklets?\).*[.]\(jpe?g\|png\|gif\|bmp\)" \;)"
album_cover="$(echo -n "$album_cover" | grep -iv '\(back\|cd\)\.' | head -n1)"
}
main() {

View file

@ -70,4 +70,4 @@ t = slideshow +1
<Shift+T> = slideshow -1
# 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"
Y="2"
WIDTH="$FZF_PREVIEW_COLUMNS"
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
function maketemp() {
if [ ! -d "$(dirname "$TMP$1")" ]; then
mkdir -p "$(dirname "$TMP$1")"
fi
maketemp() {
[ ! -d "$TMP" ] && mkdir -p "$TMP"
}
function fileclean() {
if [ -f "$TMP$1.png" ]; then
rm -f "$TMP$1.png"
elif [ -d "$TMP$1/" ]; then
rm -rf "$TMP$1/"
fi
}
function previewclear() {
previewclear() {
kitty +kitten icat --transfer-mode=file --silent --clear
}
function text() {
text() {
bat --pager=never --wrap never --style="changes" --color="always" "$1" -p
}
function torrent() {
torrent() {
aria2c --show-files "$1"
}
function archive() {
archive() {
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"
}
function image() {
image() {
draw "$1"
}
function audio() {
maketemp "$1"
if [ ! -f "$TMP$1.png" ]; then
# https://ffmpeg.org/ffmpeg-filters.html#showspectrum-1
ffmpeg -loglevel 0 -y -i "$1" -lavfi "showspectrumpic=s=hd480:legend=0:gain=5:color=intensity" "$TMP$1.png"
fi
draw "$TMP$1.png"
# https://ffmpeg.org/ffmpeg-filters.html#showspectrum-1
audio() {
[ ! -f "$CACHEFILE" ] && ffmpeg -loglevel 0 -y -i "$1" -lavfi "showspectrumpic=s=hd480:legend=0:gain=5:color=intensity" "$CACHEFILE"
draw "$CACHEFILE"
}
function video() {
maketemp "$1"
if [ ! -f "$TMP$1.png" ]; then
ffmpegthumbnailer -i "$1" -o "$TMP$1.png" -s 1024 -q 10
fi
draw "$TMP$1.png"
video() {
[ ! -f "$CACHEFILE" ] && ffmpegthumbnailer -i "$1" -o "$CACHEFILE" -s 1024 -q 10
draw "$CACHEFILE"
}
function pdf() {
maketemp "$1"
if [ ! -f "$TMP$1.png" ]; then
pdftoppm -png -singlefile "$1" "$TMP$1" -scale-to 1024
fi
draw "$TMP$1.png"
pdf() {
[ ! -f "$CACHEFILE.png" ] && pdftoppm -png -singlefile "$1" "$CACHEFILE" -scale-to 1024
draw "$CACHEFILE.png"
}
function epub() {
maketemp "$1"
if [ ! -f "$TMP$1.png" ]; then
epub-thumbnailer "$1" "$TMP$1.png" 1024
fi
draw "$TMP$1.png"
epub() {
[ ! -f "$CACHEFILE" ] && epub-thumbnailer "$1" "$CACHEFILE" 1024
draw "$CACHEFILE"
}
function main() {
mimetype=$(file -b --mime-type "$1")
main() {
previewclear
if [ $mimetype != "inode/directory" ]; then
fileclean "$1"
fi
maketemp
mimetype=$(file -b --mime-type "$1")
case $mimetype in
application/epub*)
@ -94,7 +68,7 @@ function main() {
pdf "$1";;
application/x-bittorrent)
torrent "$1";;
application/zip | application/x-tar | *rar )
application/zip | application/x-tar | *rar | application/gzip )
archive "$1";;
audio/*)
audio "$1";;
@ -105,8 +79,9 @@ function main() {
video/*)
video "$1";;
inode/directory)
exa --color always "$1";;
*);;
[ -z "${1##*/..*}" ] && echo || exa -Fa --color always "$1";;
*)
text "$1";;
esac
}

View file

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