1
submitted 5 months ago* by [M] to c/bashing@sh.itjust.works
 
 

Requirements: moreutils, which contains vipe command, Wayland for clipboard. vipe is a command that takes in text, creates a temporary file with that text, and prints the content in the editor when it closes.

Code:

# Change editor if necessary. Also see the notes below.
# export EDITOR="kate -b"
wl-paste | vipe | wl-copy -n 2>/dev/null

How it works:

wl-paste: Gets your clipboard content, and print that

vipe: Gets the printed clipboard content, open an editor pre-filled with it

wl-copy: Gets the edited result, add it back to your clipboard without the newline at the end


Notes:

You must save the content in the editor before quitting.

The editor must not run detached. Otherwise, vipe thinks the editor is done editing, and does nothing. For example, use environment variable EDITOR="kate -b" (flag to make kate to run in blocking mode) to use kate for editing your clipboard.

2
Rotate PDF (sh.itjust.works)
submitted 6 months ago by [M] to c/bashing@sh.itjust.works
 
 

Requirements: pdfjam. Looks like some major projects depend on this? I never knew this was installed on my laptop.

Code:

pdfjam --outfile "$@" --angle 270 --fitpaper true --rotateoversize true "$@" # Clockwise
pdfjam --outfile "$@" --angle 90 --fitpaper true --rotateoversize true "$@" # Anti-clockwise

Note: For some reason, rotating the document and reverting it (or doing it 4 times) gets you a different hash.

Bonus: Add this to Yazi config for this:

Rotate options in Yazi

[[open.rules]]
url = "*.pdf"
use = ["pdf"]

# ...

[[opener.pdf]]
desc = "Rotate Clockwise"
orphan = true
run = "pdfjam --outfile \"$@\" --angle 270 --fitpaper true --rotateoversize true \"$@\""

[[opener.pdf]]
desc = "Rotate Anticlockwise"
orphan = true
run = "pdfjam --outfile \"$@\" --angle 90 --fitpaper true --rotateoversize true \"$@\""

3
 
 

Requirements: GoCryptFS, a secret service, secret-tool for command line key access, notify-desktop for notification

Store a secret in your secret storage

# Label is the entry title in your secret storage, it doesn't matter what you choose
# The "Use" is the attribute name, and "GocryptFS_Secret_Encryption_Key" is the attribute value
# We will use the attribute key and value to find the password
secret-tool store --label "My GoCryptFS Password" Use GocryptFS_Secret_Encryption_Key
# You will now be prompted to enter a password.
# Enter the password you used to create GoCryptFS storage

Unlock script

encDir=~/Sync/Passwords/Secrets/ # Location of the encrypted files
mountDir=~/Mounts/Secrets/ # Where you want the decrypted files to appear
mkdir -p $mountDir; # That directory need to exist
notify-desktop GocryptFS "$(gocryptfs -extpass 'secret-tool lookup Use GocryptFS_Secret_Encryption_Key' $encDir $mountDir)"; # Find the key from the secret storage, unlock it, and show notification
4
 
 

Requirements: Wayland environment with slurp, grim, zbarimg installed

selected_area=$(slurp) && grim -g "$selected_area" - | zbarimg - | tee >(notify-desktop "QR Code Captured" "$(cat)") | wl-copy;

Explanation:

selected_area=$(slurp) && grim -g "$selected_area" - | # User selects an area and grim takes screenshot of it
  zbarimg - | # QR code value is extracted from it
  tee >(notify-desktop "QR Code Captured" "$(cat)") | # Copy the output and make a notification out of it
  wl-copy; # Also add the value to your clipboard