[Fish, Bin, Bootstrap] Sxiv to Nsxiv, install custom packages
All checks were successful
continuous-integration/drone/push Build is passing

Change all references of sxiv to nsxiv.

In bootstrap, install my custom packages from their PKGBUILD rather
than from repositories.
This commit is contained in:
2022-02-24 17:13:23 +01:00
parent 490772669b
commit 8bc5d228dd
4 changed files with 78 additions and 46 deletions

View File

@@ -288,12 +288,12 @@ printf "^f2^f0%s" "$UNREAD"
:END:
It is possible to call a script on the resulting image of a ~scrot~
command. Not only do I want to move them to a specific directory, I
also want to be able to see them in ~sxiv~ in case I want to edit the
image, copy it or simply delete it (sometimes I take screenshots by
accident).
also want to be able to see them in ~nsxiv~ (a replacement for ~sxiv~) in
case I want to edit the image, copy it or simply delete it (sometimes
I take screenshots by accident).
#+begin_src sh
mv "$@" ~/Pictures/Screenshots/
sxiv -abfs f "$HOME/Pictures/Screenshots/$*"
nsxiv -abfs f "$HOME/Pictures/Screenshots/$*"
#+end_src
** sshbind
@@ -309,33 +309,33 @@ intuitive way of writing it. Its usage is ~sshbind PORT FROMHOST TOHOST~.
ssh -L $argv[1]:$argv[3]:$argv[1] $argv[2] -N
#+END_SRC
** Sxiv key handler
** Nsxiv key handler
:PROPERTIES:
:HEADER-ARGS: :mkdirp yes :tangle no :noweb yes
:CUSTOM_ID: cli-utilities-Sxiv-key-handler-atganx41adj0
:END:
One thing I like with ~sxiv~ is you can trigger different behaviors
based on keypresses. For instance, with my current sxiv configuration,
One thing I like with ~nsxiv~ is you can trigger different behaviors
based on keypresses. For instance, with my current nsxiv configuration,
if I press the space key followed by a character, it can delete to the
trashcan, delete definitively, or open the current image in GIMP. All
of that is done through one script file stored in
~$HOME/.config/sxiv/exec/key-handler~. The fact it reacts to first the
spacebar instead of /Ctrl-x/ is because I use a custom version of sxiv I
~$HOME/.config/nsxiv/exec/key-handler~. The fact it reacts to first the
spacebar instead of /Ctrl-x/ is because I use a custom version of nsxiv I
first modified to fit the bépo layout, and then I decided to change
the prefix to fit how I use Emacs and StumpWM. You can read the
PKGBUILD and my sxiv patch [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/Documents/code/PKGBUILDs/sxiv][in my dotfiles repo]].
PKGBUILD and my nsxiv patch [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/Documents/code/PKGBUILDs/sxiv][in my dotfiles repo]].
#+header: :shebang "#!/usr/bin/env fish" :tangle ~/.config/sxiv/exec/key-handler
#+header: :shebang "#!/usr/bin/env fish" :tangle ~/.config/nsxiv/exec/key-handler
#+begin_src fish
<<sxiv-read-files>>
<<nsxiv-read-files>>
<<sxiv-switch-statement>>
<<nsxiv-switch-statement>>
#+end_src
Here is a step by step explanation of the source code. First, we want
to store in the variable ~FILES~ all the files marked in sxiv. This is
to store in the variable ~FILES~ all the files marked in nsxiv. This is
done with a ~while~ loop and the ~read~ command.
#+name: sxiv-read-files
#+name: nsxiv-read-files
#+begin_src fish
while read file
set -g FILES "$file" $FILES
@@ -344,22 +344,22 @@ end
We can then read from the first member of ~argv~ which key the user
pressed. Depending on it, we can chose what to execute.
#+name: sxiv-switch-statement
#+name: nsxiv-switch-statement
#+begin_src fish
switch "$argv[1]"
<<sxiv-trash>>
<<sxiv-rm>>
<<sxiv-gimp>>
<<sxiv-jpeg>>
<<sxiv-rotate-clockwise>>
<<sxiv-rotate-counter-clockwise>>
<<sxiv-yank>>
<<nsxiv-trash>>
<<nsxiv-rm>>
<<nsxiv-gimp>>
<<nsxiv-jpeg>>
<<nsxiv-rotate-clockwise>>
<<nsxiv-rotate-counter-clockwise>>
<<nsxiv-yank>>
end
#+end_src
The first option with the letter ~d~ is to move the file to the trash
can. For this, we use the ~trash~ command from ~trash-cli~.
#+name: sxiv-trash
#+name: nsxiv-trash
#+begin_src fish
case "d"
trash $FILES
@@ -367,29 +367,29 @@ case "d"
In case we want to definitively delete a file without using the trash
can, we can use ~rm~ instead when we press the ~D~ key.
#+name: sxiv-rm
#+name: nsxiv-rm
#+begin_src fish
case "D"
rm $FILES
#+end_src
Its not rare I want to modify an image I have open in sxiv,
Its not rare I want to modify an image I have open in nsxiv,
especially since screenshots are automatically open in this image
viewer aften they are taken. In that case, a simple command will do.
#+name: sxiv-gimp
#+name: nsxiv-gimp
#+begin_src fish
case "g"
gimp $FILES
#+end_src
Often, I use sxiv to convert an image to a jpeg file, because my
Often, I use nsxiv to convert an image to a jpeg file, because my
internet connection is not that great and jpeg screenshots are faster
to upload than png screenshots. So what I do is for each file
selected, I take the base name of the file (i.e. remove its
extension), and then I use the ~convert~ command from ~imagemagik~ to
convert it from its original format to a jpg format --- ~imagemagik~
detects the formats based on the extension.
#+name: sxiv-jpeg
#+name: nsxiv-jpeg
#+begin_src fish
case "j"
for f in $FILES
@@ -401,7 +401,7 @@ case "j"
I have two commands to rotate my files, and both only differ by the
angle of rotation. Once again I rely on ~convert~ in both cases. To
rotate clockwise, this is the code needed.
#+name: sxiv-rotate-clockwise
#+name: nsxiv-rotate-clockwise
#+begin_src fish
case "r"
for f in $FILES
@@ -410,7 +410,7 @@ case "r"
#+end_src
On the other hand, to rotate counter-clockwise, we need this code:
#+name: sxiv-rotate-counter-clockwise
#+name: nsxiv-rotate-counter-clockwise
#+begin_src fish
case "R"
for f in $FILES
@@ -424,7 +424,7 @@ mimetype of the image, then I can pass it to ~xclip~ along with the
filename to copy it to the clipboard. In this case, we only copy the
first of the selected files since the clipboard cannot hold several
files at once.
#+name: sxiv-yank
#+name: nsxiv-yank
#+begin_src fish
case "y"
set FILE "$FILES[1]"
@@ -2060,10 +2060,10 @@ set-pape "$PAPE"
:CUSTOM_ID: Wallpaper-utilities-Select-wallpaper-42f477a9
:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/select-pape
:END:
This script is based on what ~sxiv~ can do as an image viewer as well as
This script is based on what ~nsxiv~ can do as an image viewer as well as
xwallpaper.
#+BEGIN_SRC sh
PAPE=$(sxiv -orbft ~/Pictures/Wallpapers/*)
PAPE=$(nsxiv -orbft ~/Pictures/Wallpapers/*)
set-pape "$PAPE"
#+END_SRC