[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:
Lucien Cartier-Tilet 2022-02-24 17:13:23 +01:00
parent 490772669b
commit 8bc5d228dd
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
4 changed files with 78 additions and 46 deletions

View File

@ -234,15 +234,18 @@ nemo \
nemo-fileroller \
nemo-preview \
obs-studio \
rofi \
sent \
sxiv
rofi
printf "\n# Installing APPSPKG ##################################################\n\n"
for pkg in $APPSPKG
paru -S --skipreview --needed $pkg
end
cd /home/phundrak/Documents/code/PKGBUILDs/emacs && makepkg -si; cd ..
cd /home/phundrak/Documents/code/PKGBUILDs/nsxiv && makepkg -si; cd ..
cd /home/phundrak/Documents/code/PKGBUILDs/pumopm-git && makepkg -si; cd ..
cd /home/phundrak/Documents/code/PKGBUILDs/sent && makepkg -si; cd ..
mkdir -p $HOME/.config/fish
mkdir -p $HOME/.config/gtk-2.0
mkdir -p $HOME/.config/gtk-3.0

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

View File

@ -440,8 +440,6 @@ Lets install some desktop applications too, shall we?
| nemo-preview | Quick file previewer for Nemo |
| obs-studio | Simply the best screen recording and streaming software |
| rofi | A beautiful ~dmenu~ replacement |
| sent | Dead simple presentation tool |
| sxiv | The best keyboard-driven image viewer (after Emacs) |
All these packages will be installed with the command ~paru -S
--skipreview --needed~ so it wont nag me about the PKGBUILD when I
@ -457,7 +455,7 @@ installed it paru wont try to reinstall it.
(mapconcat #'identity packages " \\\n"))
#+end_src
#+RESULTS[c695e04be22173bb49245f65a25c375d0ad865bf]: gen-package-list
#+RESULTS[3ba0427505dea021df862ce544adec325416ecf1]: gen-package-list
#+begin_src fish :exports none :tangle no
set APPS bitwarden \
discord \
@ -468,8 +466,7 @@ nemo-fileroller \
nemo-preview \
obs-studio \
rofi \
sent \
sxiv
sent
#+end_src
#+name: gen-package-install
@ -519,6 +516,38 @@ end
<<gen-package-install(varname="APPSPKG")>>
#+end_src
Finally, I wish to install some custom packages for which Ive written
a ~PKGBUILD~ file myself. I store all of them in a dedicated directory
located in ~$HOME/Documents/code/PKGBUILDs~. I want to install some of
them immediately.
#+name: packages-pkgbuild
| Package Name | What it is |
|--------------+------------------------------------------------------------------|
| emacs | My custom Emacs build, it will replace the one already installed |
| nsxiv | The best image viewer after Emacs |
| pumopm-git | My very simple battery manager |
| sent | A very simple presentation tool |
#+name: gen-package-pkgbuild
#+header: :wrap "src fish :exports none"
#+header: :exports none
#+begin_src emacs-lisp :var packages=packages-pkgbuild[,0]
(let ((base-dir "~/Documents/code/PKGBUILDs"))
(mapconcat (lambda (dir)
(format "cd %s && makepkg -si; cd .."
(expand-file-name dir base-dir)))
packages
"\n"))
#+end_src
#+RESULTS[82db1c3f1b9c80b3c24075d1a20933be59baac47]: gen-package-pkgbuild
#+begin_src fish :exports none
cd /home/phundrak/Documents/code/PKGBUILDs/emacs && makepkg -si; cd ..
cd /home/phundrak/Documents/code/PKGBUILDs/nsxiv && makepkg -si; cd ..
cd /home/phundrak/Documents/code/PKGBUILDs/pumopm-git && makepkg -si; cd ..
cd /home/phundrak/Documents/code/PKGBUILDs/sent && makepkg -si; cd ..
#+end_src
** Tangle configuration files from Org files
:PROPERTIES:
:CUSTOM_ID: Execute_bootstrap-Tangle_configuration_files_from_Org_files-cc524361

View File

@ -625,11 +625,11 @@ videoIdentifier~ to get it through ~youtube-dl~.
abbr flac 'youtube-dl -x --audio-format flac --audio-quality 0 -o "~/Music/%(uploader)s/%(title)s.%(ext)s"'
#+END_SRC
Some sane default options for ~sxiv~, a simple X image Viewer. This includes
playing GIFs and not displaying the filename below. Sxiv will also open in
fullscreen and will fit the displayed image to the frame.
Some sane default options for [[https://github.com/nsxiv/nsxiv][~nsxiv~]]. This includes playing GIFs and
not displaying the filename below. Nsxiv will also open in fullscreen
and will fit the displayed image to the frame.
#+BEGIN_SRC fish
abbr sxiv 'sxiv -abfs f'
abbr nsxiv 'nsxiv -abfs f'
#+END_SRC
Finally, let's declare the following abbreviation that will launch an mpv