Update css/js + few configs

This commit is contained in:
2021-01-01 20:12:34 +01:00
parent 2cfa706a42
commit 85e9caebe4
95 changed files with 15754 additions and 16561 deletions

View File

@@ -1,109 +1,14 @@
#+TITLE: Binaries
:DRAWER:
#+STARTUP: overview
#+LANGUAGE: en
#+EMAIL: dehaeze.thomas@gmail.com
#+AUTHOR: Dehaeze Thomas
#+HTML_LINK_HOME: ./index.html
#+HTML_LINK_UP: ./index.html
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/bootstrap.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="./js/readtheorg.js"></script>
#+SETUPFILE: ./setup/org-setup-file.org
#+PROPERTY: header-args:bash :comments both :mkdirp yes
#+PROPERTY: header-args:bash+ :shebang "#!/usr/bin/env bash"
:END:
* =displayselect= - Select Screen
Script taken from Luke Smith.
#+begin_src bash :tangle ~/.local/bin/displayselect
twoscreen() { # If multi-monitor is selected and there are two screens.
mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
# Mirror displays using native resolution of external display and a scaled
# version for the internal display
if [ "$mirror" = "yes" ]; then
external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
internal=$(echo "$screens" | grep -v "$external")
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
tail -n 1 | awk '{print $1}')
res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
tail -n 1 | awk '{print $1}')
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
res_int_x=$(echo "$res_internal" | sed 's/x.*//')
res_int_y=$(echo "$res_internal" | sed 's/.*x//')
scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
xrandr --output "$external" --auto --scale 1.0x1.0 \
--output "$internal" --auto --same-as "$external" \
--scale "$scale_x"x"$scale_y"
else
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
fi
}
morescreen() { # If multi-monitor is selected and there are more than two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
}
multimon() { # Multi-monitor handler.
case "$(echo "$screens" | wc -l)" in
2) twoscreen ;;
,*) morescreen ;;
esac ;}
onescreen() { # If only one output available or chosen.
xrandr --output "$1" --auto --scale 1.0x1.0 "$(echo "$allposs" | grep -v "$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ')"
}
postrun() { # Stuff to run to clean up.
setbg # Fix background if screen size/arangement has changed.
$HOME/.config/polybar/scripts/launch.sh # restart polybar
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
}
# Get all possible displays
allposs=$(xrandr -q | grep "connected")
# Get all connected screens.
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
{ onescreen "$screens"; postrun; notify-send "💻 Only one screen detected." "Using it in its optimal settings..."; exit ;}
# Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in
"manual selection") arandr ; exit ;;
"multi-monitor") multimon ;;
,*) onescreen "$chosen" ;;
esac
postrun
#+end_src
* =dmenumount= - Mount USB and Android
:PROPERTIES:
:CUSTOM_ID: dmenumount
:END:
Script taken from Luke Smith.
#+begin_src bash :tangle ~/.local/bin/dmenumount
@@ -169,6 +74,10 @@ Script taken from Luke Smith.
#+end_src
* =dmenuumount= - Unmount USB and Android devices
:PROPERTIES:
:CUSTOM_ID: dmenuumount
:END:
Script taken from Luke Smith.
#+begin_src bash :tangle ~/.local/bin/dmenuumount
@@ -212,18 +121,36 @@ Script taken from Luke Smith.
fi
#+end_src
* =vpntoggle= - Connect to VPN using NordVPN
#+begin_src bash :tangle ~/.local/bin/vpntoggle
* =nordvpn-toggle= - Connect to VPN using NordVPN
:PROPERTIES:
:CUSTOM_ID: nordvpn-toggle
:END:
To use this this, =nordvpn= must be installed: =yay -S nordvpn-bin=.
#+begin_src bash :tangle ~/.local/bin/nordvpn-toggle
tmpfile="/tmp/vpnstatus";
if [[ $(nordvpn status) == *"Connected"* ]]; then
nordvpn disconnect && dunstify --replace=23198 "VPN" "Disconnected";
nordvpn disconnect && \
dunstify --replace=23198 "VPN" "Disconnected" && \
echo "off" > $tmpfile;
else
country=`cat ~/.local/data/nordvpn_countries.txt | sed 's/\s*\t\s*/ /g ; s/\s/\n/g ; s/_/ /g ; /^[a-zA-Z]/!d ; s/\(.*\)/\L\1/' | rofi -i -dmenu | sed 's/\s/_/g'`;
dunstify --replace=23198 "VPN" "Connecting to $country...";
nordvpn connect $country && dunstify --replace=23198 "VPN" "Connected to $country";
# Select Country to connect to
country=`cat ~/.local/data/nordvpn_countries.txt | rofi -i -dmenu | sed 's/\s/_/g'`;
dunstify --replace=23198 "VPN" "Connecting to $country...";
nordvpn connect $country && \
dunstify --replace=23198 "VPN" "Connected to $country" && \
echo "on" > $tmpfile;
fi
#+end_src
* =bukurun= - Open link from Buku
:PROPERTIES:
:CUSTOM_ID: bukurun
:END:
Script taken from [[https://github.com/carnager/buku_run][here]] that acts as a buku frontend using Rofi.
#+begin_src bash :tangle ~/.local/bin/bukurun
_rofi () {
@@ -559,6 +486,9 @@ Script taken from Luke Smith.
#+end_src
* =i3exit= - Manage lock, suspend, reboot, ...
:PROPERTIES:
:CUSTOM_ID: i3exit
:END:
#+begin_src bash :tangle ~/.local/bin/i3exit
option=$(echo -e "Lock\nExit\nLogout\nSuspend\nHibernate\nReboot\nShutdown" | rofi -i -dmenu)
@@ -568,7 +498,7 @@ Script taken from Luke Smith.
~/.local/bin/lockscreen
;;
"Exit")
dm-tool switch-to-greeter
pkill -15 -t tty"$XDG_VTNR" Xorg
;;
"Logout")
loginctl terminate-session `loginctl session-status | head -n 1 | awk '{print $1}'`
@@ -604,8 +534,13 @@ Script taken from Luke Smith.
#+end_src
* =askpass-rofi= - GUI prompt for passwords
:PROPERTIES:
:CUSTOM_ID: askpass-rofi
:END:
Take password prompt from STDIN, print password to STDOUT.
The sed piece just removes the colon from the provided prompt: =rofi -p= already gives us a colon
#+BEGIN_SRC bash :tangle ~/.local/bin/askpass-rofi
rofi -dmenu \
-password \
@@ -614,37 +549,55 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
#+END_SRC
* =screenshot= - Take Screenshot
:PROPERTIES:
:CUSTOM_ID: screenshot
:END:
#+begin_src bash :tangle ~/.local/bin/screenshot
status=$(echo -e "All\nGUI\nSelection\nCropped\nCopy\nShadow\nActive" | rofi -i -dmenu -p "Type")
# Ask for screenshot type
status=$(echo -e "All\nGUI\nSelection\nCropped\nCopy\nPretty\nShadow\nWindow" | rofi -i -dmenu -p "Type")
if [ -z "$status" ]; then
exit;
exit;
fi
name=$(echo -e "screenshot-$(date +"%m-%d-%y_%H-%M-%S")" | rofi -i -dmenu -p "Filename")
if [ -z "$name" ]; then
exit;
# Ask for filename if not copying the image
if [[ $status != "Copy" ]]; then
name=$(echo -e "screenshot-$(date +"%m-%d-%y_%H-%M-%S")" | rofi -i -dmenu -p "Filename")
if [ -z "$name" ]; then
exit;
fi
filename=~/Pictures/$name.png
fi
case "$status" in
"All")
maim ~/Pictures/$name.png ;;
maim -u $filename ;;
"GUI")
flameshot gui -r > ~/Pictures/$name.png ;;
flameshot gui -r > $filename && \
pkill flameshot;;
"Selection")
maim -s ~/Pictures/$name.png ;;
maim -u -s $filename ;;
"Cropped")
maim -s ~/Pictures/$name.png && convert -trim ~/Pictures/$name.png ~/Pictures/$name.png;;
maim -u -s $filename && convert -trim $filename $filename ;;
"Copy")
maim -s | xclip -selection clipboard -t image/png ;;
maim -u -s | xclip -selection clipboard -t image/png ;;
"Shadow")
maim -st 9999999 | convert - \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage ~/Pictures/$name.png ;;
"Active")
maim -i $(xdotool getactivewindow) ~/Pictures/$name.png ;;
maim -u -s | convert - \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage $filename ;;
"Pretty")
maim -u -s $filename && \
convert $filename \( +clone -alpha extract -draw 'fill black polygon 0,0 0,5 5,0 fill white circle 5,5 5,0' \( +clone -flip \) -compose Multiply -composite \( +clone -flop \) -compose Multiply -composite \) -alpha off -compose CopyOpacity -composite $filename && \
convert $filename \( +clone -background black -shadow 40x5+0+0 \) +swap -background none -layers merge +repage $filename ;;
"Window")
maim -u -i $(xdotool selectwindow) $filename ;;
esac
#+end_src
* =network-toggle= - Toggle Network
:PROPERTIES:
:CUSTOM_ID: network-toggle
:END:
Minimal network manager to just toggle the Wifi or Ethernet connection.
#+begin_src bash :tangle ~/.local/bin/network-toggle
result=$(nmcli device | sed '1d' | dmenu -l 20);
@@ -659,11 +612,15 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
fi
#+end_src
* =make-gif= - Make GIF
* =make-gif= - Convert an =MP4= video to =GIF=
:PROPERTIES:
:CUSTOM_ID: make-gif
:END:
First argument is the =mp4= file and the second argument is the output =gif= file.
#+begin_src bash :tangle ~/.local/bin/make-gif
palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
@@ -671,6 +628,9 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
#+end_src
* =yt-audio= - Download-Audio from youtube
:PROPERTIES:
:CUSTOM_ID: yt-audio
:END:
#+begin_src bash :tangle ~/.local/bin/yt-audio
if [ $TMUX ]; then
@@ -682,6 +642,9 @@ fi
#+end_src
* =yt-video= - Download-Video from youtube
:PROPERTIES:
:CUSTOM_ID: yt-video
:END:
#+begin_src bash :tangle ~/.local/bin/yt-video
if [ $TMUX ]; then
@@ -692,18 +655,33 @@ else
fi
#+end_src
* =setbg= - Set Background
:PROPERTIES:
:CUSTOM_ID: setbg
:END:
First argument is either:
- the background file
- a directory, in such case it will pick a random picture file from that directory
#+begin_src bash :tangle ~/.local/bin/setbg
bgloc="${XDG_CACHE_HOME:-$HOME/.cache/}/bg"
# If the argument is a file
[ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc"
# If the argument is a directory
[ -d "$1" ] && ln -sf "$(find "$(readlink -f "$1")" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc"
# Set the wallpaper
xwallpaper --zoom "$bgloc"
#+end_src
* =insert-unicode= - Insert Unicode Icon
:PROPERTIES:
:CUSTOM_ID: insert-unicode
:END:
The list of emojis is available [[file:data.org::#emojis][here]].
#+begin_src bash :tangle ~/.local/bin/insert-unicode
# Must have xclip installed to even show menu.
@@ -723,6 +701,11 @@ fi
#+end_src
* =insert-nerd-fonts= - Insert Nerd Font Icon
:PROPERTIES:
:CUSTOM_ID: insert-nerd-fonts
:END:
The list of emojis is available [[file:data.org::#nerd-fonts][here]].
#+begin_src bash :tangle ~/.local/bin/insert-nerd-fonts
# Must have xsel installed to even show menu.
@@ -742,92 +725,71 @@ fi
#+end_src
* =linkhandler= - Open with Default application
Inspired from =linkhandler= https://github.com/LukeSmithxyz/voidrice/
This is used in =newsboat= to handle links
:PROPERTIES:
:CUSTOM_ID: linkhandler
:END:
Inspired from =linkhandler= script ([[https://github.com/LukeSmithxyz/voidrice/][github]]).
This is used to open any type of file with the wanted program.
It can be used in =newsboat=, =neomutt= and =ranger= for instance.
#+begin_src bash :tangle ~/.local/bin/linkhandler
[ -z "$1" ] && { "$BROWSER"; exit; }
case "$1" in
,*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*)
,*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*)
setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;;
,*png|*jpg|*jpe|*jpeg|*gif)
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
,*mp3|*flac|*opus|*mp3?source*)
setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
setsid curl -LO "$1" >/dev/null 2>&1 & ;;
,*)
if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
else setsid $BROWSER "$1" >/dev/null 2>&1 & fi ;;
esac
#+end_src
* =lockscreen= - LockScreen
* =lockscreen= - Lock Screen
:PROPERTIES:
:CUSTOM_ID: lockscreen
:header-args: :tangle ~/.local/bin/lockscreen
:END:
First, turn off dunst
#+begin_src bash
killall -SIGUSR1 dunst && echo "off" > /tmp/dunststatus;
#+end_src
A nice lockscreen that uses =i3lock=.
It takes a screenshot, pixelize it and overlay an image in the lockscreens folder.
Turn off the music if it is playing.
#+begin_src bash
# First, turn off dunst
killall -SIGUSR1 dunst && echo "off" > /tmp/dunststatus;
# Turn off the music if it is playing.
MPC_STATE=$(mpc | sed -n '2p' | cut -d "[" -f2 | cut -d "]" -f1)
if [[ $MPC_STATE == "playing" ]]; then
mpc pause
mpc pause
fi
#+end_src
Then take a screenshot and process it.
#+begin_src bash
# Take the screenshot and process it nicely
temp_file="/tmp/screen.png"
rm -f $temp_file
maim $temp_file && \
# Pixelize the Screenshot
convert $temp_file -scale 10% -scale 1000% $temp_file && \
# Overlay a random image in the lockscreens folder
composite -gravity center $(find ~/.local/data/lockscreens/ -type f | shuf -n 1) $temp_file $temp_file;
maim $temp_file
convert $temp_file -scale 10% -scale 1000% $temp_file
#+end_src
Finally, lock the screen using =i3lock=.
#+begin_src bash
i3lock --no-unlock-indicator --ignore-empty-password --nofork --image=$temp_file && killall -SIGUSR2 dunst && echo "on" > /tmp/dunststatus
#+end_src
#+begin_src bash :tangle no
revert() {
xset dpms 0 0 0
}
trap revert HUP INT TERM
# turn off screen after 5 seconds
xset +dpms dpms 5 5 5
# Parameters
temp_file="/tmp/screen.png"
icon="$HOME/Pictures/Evil_Rick_Sprite.png"
width=1920
height=1080
blur_factor=6
lock_blur_factor=0
# Take the screen shot, blur the image and add the icon
ffmpeg -f x11grab -video_size "${width}x${height}" -y -i $DISPLAY -i $icon -filter_complex "boxblur=$blur_factor:$blur_factor,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2,boxblur=$lock_blur_factor:$lock_blur_factor" -vframes 1 $temp_file
# Alternative
# maim -d 1 $temp_file
# convert -blur 0x8 $temp_file $temp_file
# convert -composite $temp_file $icon -gravity South -geometry -20x1200 $temp_file
# Lock the screen with the image
i3lock --no-unlock-indicator --ignore-empty-password --show-failed-attempts --nofork --image=$temp_file
# Remove the screenshot
rm $temp_file
# Don't turn off screen when back from lock
revert
# Finally, lock the screen using =i3lock=
i3lock --ignore-empty-password --nofork --image=$temp_file && \
# When unlocking, restart dunst
killall -SIGUSR2 dunst && echo "on" > /tmp/dunststatus
#+end_src
* =mopidy-restart= - Restart Mopidy
:PROPERTIES:
:CUSTOM_ID: mopidy-restart
:END:
Sometimes =mopidy= need to be restarted...
#+begin_src bash :tangle ~/.local/bin/mopidy-restart
pids=( $(pgrep -f mopidy) )
@@ -836,14 +798,20 @@ Finally, lock the screen using =i3lock=.
kill "$pid"
fi
done
echo "Killed mopidy."
echo "Restarting mopidy..."
mopidy --config ~/.config/mopidy/mopidy.conf >/dev/null 2>&1 &
echo "Done"
#+end_src
* =upload= - Upload Script
:PROPERTIES:
:CUSTOM_ID: upload
:END:
Upload a file to https://0x0.st/ and copy the generated url.
#+begin_src bash :tangle ~/.local/bin/upload
if [ $TMUX ]; then
tmux split -v -l 1 "curl --progress-bar -F\"file=@$1\" https://0x0.st | xsel -ib;" && tmux select-pane -U
@@ -855,6 +823,12 @@ Finally, lock the screen using =i3lock=.
#+end_src
* =weather= - Display Weather in terminal
:PROPERTIES:
:CUSTOM_ID: weather
:END:
Get the weather from http://wttr.in/.
#+begin_src bash :tangle ~/.local/bin/weather
if [ -n "$*" ]; then
address="wttr.in/"
@@ -878,16 +852,21 @@ Finally, lock the screen using =i3lock=.
#+end_src
* =readbib= - Open Bibliography File
:PROPERTIES:
:CUSTOM_ID: readbib
:END:
List all =pdf= files and open selected one with zathura.
#+begin_src bash :tangle ~/.local/bin/readbib
cd ~/Cloud/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {}
#+end_src
* =readnotes= - Open Note File
#+begin_src bash :tangle ~/.local/bin/readnotes
cd ~/Cloud/thesis/ressources/notes/pdfs/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}
#+end_src
* =pdf2bib= - Extract bibtex entry from PDF file
:PROPERTIES:
:CUSTOM_ID: pdf2bib
:END:
#+begin_src bash :tangle ~/.local/bin/pdf2bib
pdf2doi () {
pdfinfo "$1" | grep -io "doi:.*" | grep -Poi "10.\d+/[^\s]+" || \
@@ -919,13 +898,143 @@ Finally, lock the screen using =i3lock=.
#+end_src
* =pdf2png= - Convert a PDF to PNG
:PROPERTIES:
:CUSTOM_ID: pdf2png
:END:
#+begin_src bash :tangle ~/.local/bin/pdf2png
# Check if the input argumetn is a PDF file
if [[ -f "$1" && "$1" == *.pdf ]]; then
pdftoppm -png "$1" > "$(echo "$1" | cut -f 1 -d '.' | sed 's/$/.png/')"
fi
#+end_src
* =convert-file= - Convert any file to another filetype
:PROPERTIES:
:CUSTOM_ID: convert-file
:END:
#+begin_src bash :tangle ~/.local/bin/convert-file
# Get filename
filename_with_extension=$(basename -- "$1")
# Extract extension of the file
in_ext="${filename_with_extension##*.}"
# filename without extension
filename_without_extension=${filename_with_extension%.*}
# Convert SVG Files
svg2() { \
out_ext=$(echo -e "pdf\npng" | rofi -i -dmenu -p "Convert SVG to")
if [ -z "$out_ext" ]; then
exit;
fi
case "$out_ext" in
"png")
inkscape --export-type="$out_ext" --export-dpi=200 --export-area-drawing "$filename_with_extension"
;;
"pdf")
inkscape --export-type="$out_ext" "$filename_with_extension"
# pdf2svg file.pdf file.svg
;;
esac
}
# Convert PDF Files
pdf2() { \
out_ext=$(echo -e "svg\npng" | rofi -i -dmenu -p "Convert PDF to")
# Ask if crop?
if [ -z "$out_ext" ]; then
exit;
fi
case "$out_ext" in
"png")
inkscape --export-type="$out_ext" --export-dpi=200 --export-area-drawing "$filename_with_extension"
;;
"svg")
inkscape --export-type="$out_ext" "$filename_with_extension"
;;
esac
}
# Convert DOCX/PPTX Files
docx2() { \
out_ext=$(echo -e "pdf" | rofi -i -dmenu -p "Convert DOCX/PPTX to")
if [ -z "$out_ext" ]; then
exit;
fi
case "$out_ext" in
"pdf")
lowriter --convert-to pdf "$filename_with_extension"
;;
esac
}
# Convert PNG Files
png2() { \
out_ext=$(echo -e "pdf" | rofi -i -dmenu -p "Convert PNG to")
if [ -z "$out_ext" ]; then
exit;
fi
case "$out_ext" in
"pdf")
convert "$filename_with_extension" "$filename_without_extension.pdf"
;;
esac
}
# Convert MP4 Files
mp42() { \
out_ext=$(echo -e "gif" | rofi -i -dmenu -p "Convert MP4 to")
if [ -z "$out_ext" ]; then
exit;
fi
case "$out_ext" in
"gif")
make-gif "$filename_with_extension" "$filename_without_extension.gif"
;;
esac
}
case "$in_ext" in
"svg")
svg2
;;
"pdf")
pdf2
;;
"mp4")
mp42
;;
"png")
png2
;;
"docx")
docx2
;;
"pttx")
docx2
;;
esac
#+end_src
* =pdf-shrink= - Pdf Shrink
:PROPERTIES:
:CUSTOM_ID: pdf-shrink
:END:
Simply reduces the size of a given pdf file.
#+begin_src bash :tangle ~/.local/bin/pdf-shrink
shrink ()
{
@@ -984,7 +1093,7 @@ Finally, lock the screen using =i3lock=.
OFILE="-"
fi
# Output resolution defaults to 72 unless given:
# Output resolution defaults to 90 unless given:
if [ ! -z "$3" ]; then
res="$3"
else
@@ -996,20 +1105,31 @@ Finally, lock the screen using =i3lock=.
check_smaller "$IFILE" "$OFILE"
#+end_src
* =pdf-delete-annotations= - Delete Annotations from PDFs
From: https://gist.github.com/stefanschmidt/5248592
:PROPERTIES:
:CUSTOM_ID: pdf-delete-annotations
:END:
Taken from this [[https://gist.github.com/stefanschmidt/5248592][gist]].
#+begin_src bash :tangle ~/.local/bin/pdf-delete-annotations
pdftk $1 output /tmp/uncompressed.pdf uncompress
LANG=C sed -n '/^\/Annots/!p' /tmp/uncompressed.pdf > /tmp/stripped.pdf
pdftk /tmp/stripped.pdf output $1 compress
# Check if the input argumetn is a PDF file
if [[ -f "$1" && "$1" == *.pdf ]]; then
pdftk $1 output /tmp/uncompressed.pdf uncompress
LANG=C sed -n '/^\/Annots/!p' /tmp/uncompressed.pdf > /tmp/stripped.pdf
pdftk /tmp/stripped.pdf output $1 compress
fi
#+end_src
* =pdf-delete-first-page= - Delete first page of PDF
:PROPERTIES:
:CUSTOM_ID: pdf-delete-first-page
:END:
The requirement is to have =pdftk= or =stapler= installed.
#+begin_src bash :tangle ~/.local/bin/pdf-delete-first-page
# Check if the input argumetn is a PDF file
if [[ -f $1 && $1 == *.pdf ]]; then
# Argument if a file
if type stapler > /dev/null 2>&1; then
stapler del "$1" 1 /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1"
elif type pdftk > /dev/null 2>&1; then
@@ -1020,18 +1140,27 @@ The requirement is to have =pdftk= or =stapler= installed.
fi
#+end_src
* =rofi-calc= - Simple Calculation using Rofi
:PROPERTIES:
:CUSTOM_ID: rofi-calc
:END:
Run some simple calculations with =rofi=.
#+begin_src bash :tangle ~/.local/bin/rofi-calc
rofi -show calc -mode calc -no-show-match -no-sort
#+end_src
* =pass-gen= - Generate Random Alphanumeric Password
:PROPERTIES:
:CUSTOM_ID: pass-gen
:END:
#+begin_src bash :tangle ~/.local/bin/pass-gen
# Ask for the wanted number of caracters
num=$(rofi -dmenu -p "Number of caracters")
# Random generation of alphanumeric caracters
pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
re='^[0-9]+$'
@@ -1039,6 +1168,19 @@ The requirement is to have =pdftk= or =stapler= installed.
pass=${pass:0:$num}
fi
# Send the password to the clipboard
printf "$pass" | xclip -sel clip && \
dunstify 'Password' 'Generated'
#+end_src
* =sxhkd-help= - List of keybindings using Rofi
:PROPERTIES:
:CUSTOM_ID: sxhkd-help
:END:
#+begin_src bash :tangle ~/.local/bin/sxhkd-help
awk '/^[a-z]/ && last {print "<small>",$0,"\t",last,"</small>"} {last=""} /^#/{last=$0}' ~/.config/sxhkd/sxhkdrc{,.i3} |
column -t -s $'\t' |
rofi -dmenu -i -markup-rows -no-show-icons -width 1000 -lines 15 -yoffset 40
#+end_src