scripts: cleanup old scripts

This commit is contained in:
Leonardo Eugênio 2024-08-20 19:21:57 -03:00
parent 2e2f2239a5
commit a7770ae62e
28 changed files with 0 additions and 924 deletions

View file

@ -1,12 +0,0 @@
#!/bin/sh
exec diffr \
--colors 'refine-added:foreground:green:underline' \
--colors 'refine-added:background:none' \
--colors 'refine-removed:foreground:red:underline' \
--colors 'refine-removed:background:none' \
--colors 'added:foreground:green' \
--colors 'added:background:none' \
--colors 'removed:foreground:red' \
--colors 'removed:background:none' \
"$@"

View file

@ -1,30 +0,0 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "_gpg-unlock" ''
${pkgs.gnupg}/bin/gpg-connect-agent reloadagent /bye
set -e
test -f "$HOME/.config/.preset-password" || {
${pkgs.libnotify}/bin/notify-send "No preset password found"
exit 0;
}
get_keygrip() {
${pkgs.gnupg}/bin/gpg --list-secret-keys --with-keygrip |
${pkgs.gawk}/bin/awk '
/^ssb/ {
ssb=1
}
/Keygrip/{
if (ssb) print $3
}'
}
keygrip=$(get_keygrip)
test -n "$keygrip" || exit 0
${pkgs.coreutils}/bin/cat "$HOME/.config/.preset-password" |
${pkgs.coreutils}/bin/base64 -d |
${pkgs.gnupg}/libexec/gpg-preset-passphrase --preset "$keygrip"
''

View file

@ -1,11 +0,0 @@
#!/bin/sh
swayidlectl() {
systemctl --user $1 swayidle.service
}
if swayidlectl status > /dev/null; then
swayidlectl stop
else
swayidlectl start
fi

View file

@ -1,10 +0,0 @@
#!/bin/sh
for path
do
test -f "$path" &&
path=$(dirname "$path")
cd "$path"
terminal
done

View file

@ -1,53 +0,0 @@
#!/usr/bin/env fish
# wrapper around bemenu
# bmenu * - use as dmenu, -p for custom prompt (man bemenu)
# bmenu run - select from .desktop files and run it
# bmenu start - internal option
if test "$argv[1]" = "run"
test -n "$argv[2]" && set t "$argv[2]" || set t "terminal"
test -n "$i3SOCK" && set wrapper 'i3-msg exec --'
test -n "$SWAYSOCK" && set wrapper 'swaymsg exec --'
exec j4-dmenu-desktop \
--dmenu="bmenu start -p Iniciar:" \
--term "$t" \
--wrapper="$wrapper" \
--no-generic
end
if test -n "$SWAYSOCK"
swaymsg -t get_outputs |
jq -r 'map(.focused)|reverse|index(true)' |
read focused_output
test -n "$focused_output"
and set focused_output "-m $focused_output"
end
set -l config "$HOME/.config/bmenu.conf"
if test -f $config
source $config
end
exec dhist wrap -- bemenu \
$focused_output\
--ignorecase\
--border 2\
--center\
--width-factor 0.5\
--no-overlap\
--list 30\
--prefix '>'\
--bdr "$bdr"\
--fn "$fn"\
--tb "$tb" --tf "$tf" \
--fb "$fb" --ff "$ff" \
--nb "$nb" --nf "$nf" \
--ab "$ab" --af "$af" \
--hb "$hb" --hf "$hf" \
$argv
# vim: ft=fish

View file

@ -1,47 +0,0 @@
#!/bin/sh
set -e -u
end(){
rm -r -- "$(dirname -- "$namebase")"
[ $# -ne 0 ] && echo $@ >&2
exit $#
}
if [ $# -ne 0 ] ; then
for i in "$@" ; do
printf "%s\n" "$i"
done | "$0"
exit $?
fi
namebase="$(mktemp -d)/blkrn"
echo '# Modify filenames without removing any line, quitting aborts' \
> "$namebase.2"
tee -- "$namebase.1" >> "$namebase.2"
exec </dev/tty >/dev/tty ||
end 'Interactive terminal needed'
"$EDITOR" -- "$namebase.2"
sed -i -- '1d' "$namebase.2"
! diff -- "$namebase.1" "$namebase.2" &> /dev/null || end "no changes"
[ `wc -l < "$namebase.1"` -eq `wc -l < "$namebase.2"` ] || end "Wrong number of lines"
{
echo '# Please review/modify this script or empty it to do nothing'
echo 'run(){'
echo ' mkdir -p "$(dirname "$2")"'
echo ' mv -T -- "$1" "$2"'
echo '}'
while read -r l1 <&3 && read -r l2 <&4; do
[ "$l1" = "$l2" ] || printf "%s\n%s\n" "$l1" "$l2"
done 3<"$namebase.1" 4<"$namebase.2" |
sed 's/\([\\"$`]\)/\\\1/g;s/^.*$/"&"/' |
xargs -d"\n" -L2 echo 'run'
} > "$namebase.sh"
"$EDITOR" -- "$namebase.sh"
sh -e -- "$namebase.sh"
end # exit normaly

View file

@ -1,10 +0,0 @@
#!/bin/sh
set -xe
grim -g "$(slurp -b aabbcc00 -p)" - |
convert - txt:- |
grep -oE '#[0-9A-Fa-f]{6}' |
wl-copy -n
notify-send "$(wl-paste)" "Copied to clipboard"

View file

@ -18,107 +18,13 @@
--suffix PATH : ${lib.makeBinPath runtimeInputs} --suffix PATH : ${lib.makeBinPath runtimeInputs}
''; '';
createScripts = lib.mapAttrs (name: deps: wrapScript name ./${name} deps); createScripts = lib.mapAttrs (name: deps: wrapScript name ./${name} deps);
myPass = final.pass.withExtensions (ex: with ex; [ pass-otp ]);
in in
with final; with final;
createScripts { createScripts {
br = [ ];
bmenu = [
bemenu
dhist
fish
j4-dmenu-desktop
jq
sway
];
down_meme = [
wl-clipboard
yt-dlp
libnotify
];
wl-copy-file = [ wl-copy-file = [
wl-clipboard wl-clipboard
fish fish
]; ];
_diffr = [ diffr ];
_thunar-terminal = [ terminal ];
_sway_idle_toggle = [ swayidle ];
helix-pager = [
fish
_diffr
];
helix-man-pager = [ helix-pager ];
musmenu = [
mpc-cli
wdmenu
trash-cli
xdg-user-dirs
libnotify
sd
wl-clipboard
];
showkeys = [ ]; # This will not work unless programs.wshowkeys is enabled systemwide
terminal = [ alacritty ];
playerctl-status = [ playerctl ];
pass-export = [
pass2csv
gnupg
sd
];
wpass = [
wdmenu
fd
myPass
sd
wl-clipboard
wtype
];
screenshotsh = [
capitaine-cursors
grim
slurp
jq
sway
wl-clipboard
xdg-user-dirs
];
volumesh = [
pulseaudio
libnotify
];
pulse_sink = [
pulseaudio
pamixer
wdmenu
];
color_picker = [
grim
slurp
wl-clipboard
libnotify
imagemagick
];
dzadd = [
procps
libnotify
wdmenu
jq
mpv
pqiv
python3Packages.deemix
mpc-cli
mpdDup
];
mpdDup = [
mpc-cli
perl
];
readQrCode = [
grim
zbar
wl-clipboard
];
auto_connect_gamepad = [ auto_connect_gamepad = [
bluez bluez
coreutils coreutils
@ -130,9 +36,4 @@
libratbag libratbag
]; ];
} }
// lib.mapAttrs importScript {
wdmenu = ./wdmenu.nix;
wlauncher = ./wlauncher.nix;
_gpg-unlock = ./_gpg-unlock.nix;
}
) )

View file

@ -1,19 +0,0 @@
#!/bin/sh
DIR=$(mktemp -d)
cd "$DIR"
yt-dlp --merge-output-format mp4 "$(wl-paste)"
FILENAME="$(ls | head -n1)"
mkdir -p "$HOME/Downloads/Memes"
cp "$FILENAME" "$HOME/Downloads/Memes/$FILENAME"
wl-copy-file "$HOME/Downloads/Memes/$FILENAME"
notify-send "Meme downloaded" "$FILENAME"
rm -rf "$DIR"

View file

@ -1,176 +0,0 @@
#!/bin/sh
set -ex
tmpf=$(mktemp /tmp/dzadd.XXXXXX)
clean() {
test "$?" -eq "0" ||
notify-send "Exiting with error"
set +e
kill "$mpvPid"
rm -f "$tmpf"
}
trap clean EXIT
main() {
sType=$(printf "Track\nAlbum\nArtist" | wdmenu | tr '[:upper:]' '[:lower:]')
test -n "$sType" || exit 1
query=$(echo -n | wdmenu | sed 's/[^ a-z0-9]//g;s/ /+/g')
test -n "$query" || exit 1
case "$sType" in
track)
deezer_category="track"
jqFilter='.data[]| "\(.title) - \(.album.title) - \(.artist.name) |\(.id)"'
;;
album)
deezer_category="album"
jqFilter='.data[]| "\(.nb_tracks) - \(.title) - \(.artist.name) |\(.id)"'
;;
artist)
deezer_category="artist"
jqFilter='.data[]| "\(.nb_fan) - \(.name) |\(.id)"'
;;
top50)
deezer_category="artist"
jqFilter='.data[]| "\(.nb_fan) - \(.name) |\(.id)"'
;;
*)
exit 1
;;
esac
curl -m30 -s "api.deezer.com/search/${deezer_category}?q=${query}" |
sed 's/|//g' |
jq -r "$jqFilter" >"$tmpf"
pick_song
}
pick_song() {
choice=$(cat "$tmpf" | cut -d\| -f1 | wdmenu)
choice=$(grep "$choice" "$tmpf" | head -n 1)
choiceId=$(printf "%s" "$choice" | cut -d\| -f2)
case "$sType" in
top50)
choiceUrl="http://deezer.com/${deezer_category}/${choiceId}/top?=limit=50"
;;
*)
choiceUrl="http://deezer.com/${deezer_category}/${choiceId}"
;;
esac
pick_action "$choiceUrl"
}
pick_action() {
choiceUrl="$1"
COMMON_CHOISES="View Image\nDownload\nCopy URL\nAnother"
choice=$(printf "Preview\n${COMMON_CHOISES}" | wdmenu)
case "$choice" in
"Preview")
common_preview
;;
"View Image")
common_art
;;
"Download")
common_download
;;
"Copy URL")
wl-copy
;;
"Another")
pick_song
;;
*)
exit 1
;;
esac
}
common_preview() {
case "$sType" in
track)
;;
album)
preview_suffix=tracks
;;
artist)
preview_suffix=top
;;
top50)
preview_suffix=top
;;
*)
exit 1
;;
esac
choicePreview=$(
curl -m30 -s "http://api.deezer.com/${deezer_category}/${choiceId}/${preview_suffix}" |
jq -r '.preview, .data[0].preview | select(. != null)'
)
mpv --quiet --volume=50 --no-resume-playback "$choicePreview" &
mpvPid="$!"
choice=$(printf "$COMMON_CHOISES" | wdmenu -p 'Download?')
kill "$mpvPid" || true
}
common_art() {
case "$sType" in
track)
image_filter='.album.cover_big'
;;
album)
image_filter='.cover_big'
;;
artist)
image_filter='.picture_big'
;;
top50)
image_filter='.picture_big'
;;
*)
exit 1
;;
esac
curl -m30 -s "api.deezer.com/${deezer_category}/${choiceId}" |
jq -r "$image_filter" |
xargs curl -m30 -s |
pqiv -
pick_action
}
common_download() {
notify-send "Starting Download"
deemix "$choiceUrl" </dev/null &&
notify-send "Download Successful" ||
notify-send "Download Failed"
mpc add /
mpdDup
}
main

View file

@ -1,3 +0,0 @@
#!/bin/sh
col -b -x | hx

View file

@ -1,28 +0,0 @@
#!/usr/bin/env fish
if test (count $argv) -ne 0
for i in $argv
cat "$i"
end | eval (status filename)
exit 0
end
set term_line_count (tput lines)
while read line
set -a input_lines "$line"
set input_line_count (printf "%s\n" $input_lines | wc -l)
if test "$term_line_count" -lt "$input_line_count"
begin
printf "%s\n" $input_lines
cat
end | hx
exit 0
end
end
printf "%s\n" $input_lines

View file

@ -1,5 +0,0 @@
#!/bin/sh
mpc playlist -f '%position%\t%file%' |
sort -k 2 |
perl -ne 'm/(.*)\t(.*)/; print "$1\n" if $2 eq $prev; $prev=$2' |
mpc del

View file

@ -1,111 +0,0 @@
#!/bin/sh
set -e
menu=wdmenu
search() {
tabs 8
mpc playlist --format '%artist% : %title%@pos:%position%' |
sed '/^ : \t/d'|
column -ts"@" |
$menu |
grep -o 'pos:.*' |
cut -d: -f2 |
xargs -r mpc play
}
get_current() {
music_root=$(xdg-user-dir MUSIC || echo "$HOME/Music")
current_file=$(mpc current -f %file%)
echo "${music_root}/${current_file}"
}
delete() {
current=$(get_current)
answer=$(printf "nothing\n$current" | $menu -p"delete?")
if test "$answer" = "$current"; then
trash "$answer"
mpc --quiet next
mpc --quiet update
path=$(echo $answer | sd "$HOME" '~')
notify-send "Removed Music" "$path"
fi
}
yank() {
current=$(get_current)
# Some programs need you to pass a path, not the contents
wl-copy --type 'text/uri-list' "file:///${current}"
notify-send "Yanked Music" "$(echo $current | sd "$HOME" "~")"
}
padd() {
get_current
cd "$music_root"
choice=$(fd -E '*.lrc' -E '*.m3u8' | sort | $menu -p "Add Songs(Use Ctrl):")
mpc add "$choice" &&
notify-send "Added Music" "$(echo $choice | sd "$HOME" "~")" ||
notify-send "Failed to Add Music" "$(echo $choice | sd "$HOME" "~")"
mpdDup
}
pclear() {
mpc clear &&
notify-send "Cleared Playlist" ||
notify-send "Failed Clear Playlist"
}
psave() {
name=$(mpc playlist | $menu -p 'Save Playlist(Use Shift): ')
mpc save "$name" &&
notify-send "Created playlist" "$name" ||
notify-send "Failed to Create Playlist" "$name"
}
pload() {
name=$(mpc lsplaylists | $menu -p 'Load Playlist: ')
mpc clear
mpc load "$name" &&
notify-send "Loaded playlist" "$name" ||
notify-send "Failed to Load Playlist" "$name"
}
pdelete() {
name=$(mpc lsplaylists | $menu -p 'Delete Playlist: ')
mpc delete "$name" &&
notify-send "Deleted playlist" "$name" ||
notify-send "Failed to Delete Playlist" "$name"
}
usage() {
cmdname=$(basename "$0")
echo "Commands:"
echo " $cmdname search -- Search and play songs."
echo " $cmdname delete -- Prompt to delete the current song."
echo " $cmdname yank -- Copy current music to clipboard."
echo "Playlist Commands:"
echo " $cmdname padd -- Add song"
echo " $cmdname pclear -- Clear"
echo " $cmdname psave -- Save"
echo " $cmdname pload -- Load"
echo " $cmdname pdelete -- Delete"
}
case "$1" in
delete | search | yank | padd | pclear | psave | pload | pdelete)
"$1"
;;
*)
usage
test -n "$1"
echo "Unreconized option: $1"
;;
esac

View file

@ -1,13 +0,0 @@
#!/bin/sh
if test -z "$PASSWORD_STORE_DIR"; then
PASSWORD_STORE_DIR="$HOME/.password-store"
fi
pass2csv "$PASSWORD_STORE_DIR" "$HOME/passwords.csv" \
-f User '(user|login)(:\s*)?' \
-f TOTP 'otpauth(:)?' \
-f URL 'url(:\s*)?'
# Fix TOTP format for keepass
sd '"//totp/.*?secret=(.*?)(&.*?)?"' '"$1"' "$HOME/passwords.csv"

View file

@ -1,10 +0,0 @@
#!/bin/sh
PLAYERCTL="playerctl --ignore-player=mpd"
test "$(LC_ALL=C $PLAYERCTL status)" = "Playing" \
&& printf " %s" "$($PLAYERCTL metadata title)" \
&& test -n "$($PLAYERCTL metadata artist)" \
&& printf " - %s" "$($PLAYERCTL metadata artist)"
echo ""

View file

@ -1,26 +0,0 @@
#!/bin/sh
list_sinks() {
env LC_ALL=C pactl list sinks
}
desc=$(
list_sinks |
grep -ie "description:" |
cut -d: -f2 |
sed 's/^ //g;s/ $//g;' |
wdmenu -i -p "Output:"
)
device=$(
list_sinks |
grep -C2 "Description: $desc"|
grep Name |
cut -d: -f2 |
xargs
)
vol=$(pamixer --get-volume)
pactl set-default-sink "$device"
pamixer --set-volume "$vol"

View file

@ -1,18 +0,0 @@
#!/bin/sh
set -o pipefail
main() {
if wl-paste | zbarimg -q --raw - | wl-copy
then
notify-send "Copied" "QrCode was copied to clipboard"
rm "$LOGFILE"
else
notify-send "Failed to read QrCode" "Log file is '$LOGFILE'"
fi
}
LOGFILE=$(mktemp /tmp/qrcode-XXXXXXXX.log)
main > "$LOGFILE" 2>&1

View file

@ -1,49 +0,0 @@
#!/bin/sh
export XCURSOR_SIZE=40
export XCURSOR_THEME='capitaine-cursors-light'
screenshot="grim"
copy="wl-copy -t image/png"
if which xdg-user-dir >/dev/null 2>&1; then
DESTFOLDER="$(xdg-user-dir PICTURES)"
else
for i in Images Imagens Pictures Fotos ""; do
DESTFOLDER="$HOME/$i"
test -d "$DESTFOLDER" &&
break
done
fi
DESTFOLDER="$DESTFOLDER/Screenshots"
mkdir -p "$DESTFOLDER"
DESTFILE="$DESTFOLDER/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')"
case $1 in
def)
# Screenshot to file
$screenshot "$DESTFILE"
echo "$DESTFILE"
;;
area)
# Screen area to file
$screenshot -g "$(slurp -d -b 30303088)" "$DESTFILE"
echo "$DESTFILE"
;;
area-clip)
# Screen area to clipboard
$screenshot -g "$(slurp -d -b 30303088)" - | $copy
;;
clip)
# Focused monitor to clipboard
cur_output=$(swaymsg -t get_outputs |
jq -r '.[] | select(.focused) | .name')
test -n "$cur_output" &&
$screenshot -o "$cur_output" - | $copy ||
$screenshot - | $copy
;;
esac

View file

@ -1,10 +0,0 @@
#!/bin/sh
pidof wshowkeys && pkill wshowkeys ||
exec wshowkeys \
-a bottom -a right \
-F 'Inter 20' \
-b 202020AA \
-s DD5050 \
-t 1 \
-m 100

View file

@ -1,18 +0,0 @@
#!/bin/sh
CLASS="terminal"
while test $# -gt 0;do
case $1 in
-c|--class)
shift
CLASS=$1
shift
;;
*)
break
;;
esac
done
exec alacritty --class "$CLASS" "$@"

View file

@ -1,139 +0,0 @@
#!/bin/sh
set -xe
# depends on: awk, pactl, pacmd, notify-send
MAX_VOL=150
STEP=10
notify() {
volume=$(get_vol_$TARGET)
if is_muted_$TARGET; then
s="Muted"
else
s="Volume"
fi
s=$(echo "${TARGET} ${s}" | sed 's/^\(.\)/\U\1/')
notify-send "${s}" "${volume}%" \
--app-name=volumesh \
--hint=int:value:"$volume"
}
round() {
awk '{
print int($1/'$STEP')*'$STEP';
}'
}
round_vol() {
rounded=$(get_vol_$TARGET | round)
newvol=$(min $MAX_VOL $rounded)
}
min() {
printf '%i\n' ${@} | sort -n | head -n1
}
# Pulse{{{
get_vol_system() {
pamixer --get-volume
}
is_muted_system() {
test "$(pamixer --get-mute)" = "true" >/dev/null
}
change_vol_system() {
pamixer "-$1" "$(min 120 $2)"
round_vol
pamixer --set-volume "${newvol}"
if
test -n "$VOLUME_CHANGE_SOUND"
then
paplay "$VOLUME_CHANGE_SOUND"
fi
}
toggle_mute_system() {
pactl set-sink-mute @DEFAULT_SINK@ toggle
}
#}}}
# Mpd {{{
get_vol_mpd() {
env LC_ALL=C mpc vol |
sed -e 's/^.*://g' -e 's/%.*$//g' -e 's/ //g'
}
is_muted_mpd() {
env LC_ALL=C mpc status | grep '\[paused\]' 1>/dev/null
}
change_vol_mpd() {
case $1 in
d)
op="-";;
i)
op="+";;
esac
mpc vol "${op}${2}" &>/dev/null
round_vol
mpc vol "${newvol}" &>/dev/null
}
toggle_mute_mpd() {
mpc toggle
}
#}}}
usage() {
local CNAME=$(basename $0)
echo "${CNAME} [-m][-di <amount>]"
echo "${CNAME} [-m][-t]"
echo ""
echo "Options:"
echo " -m --mpd Target mpd instead of PulseAudio"
echo " -i --increase <amount> of volume to increase"
echo " -d --decrease <amount> of volume to decrease"
echo " -t --toggle Mute/Unmute target"
echo " -h --help Show This help message"
exit "$1"
}
TARGET=system
while [ $# -gt 0 ]; do
case $1 in
-m | --mpd)
TARGET=mpd
shift
;;
-i | --increase)
shift
change_vol_$TARGET i $1
shift
;;
-d | --decrease)
shift
change_vol_$TARGET d $1
shift
;;
-t | --toggle)
toggle_mute_$TARGET
shift
;;
-h | --help)
usage 0
;;
*)
usage 1
;;
esac
done
notify
# vim: fdm=marker

View file

@ -1,4 +0,0 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "wdmenu" ''
exec bmenu "$@"
''

View file

@ -1,12 +0,0 @@
{ pkgs, ... }:
let
inherit (config.my) dmenu;
available_menus = {
bmenu = "bmenu run";
rofi = "rofi -show drun -sort";
};
menu_cmd = available_menus.${dmenu};
in
pkgs.writeShellScriptBin "wlauncher" ''
exec ${menu_cmd} "$@"
''

View file

@ -1,4 +0,0 @@
{ pkgs, ... }:
pkgs.writeShellScriptBin "wlauncher" ''
exec bmenu run "$@"
''

View file

@ -13,7 +13,6 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
down_meme
yt-dlp yt-dlp
ffmpeg ffmpeg
obs-studio obs-studio

View file

@ -41,9 +41,6 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
# home-manager # home-manager
terminal # see flake.nix
pulse_sink
pulseaudio pulseaudio
## CLI ## CLI
@ -56,8 +53,6 @@
p7zip p7zip
tealdeer tealdeer
micro micro
_diffr
br # bulk rename
comma comma

View file

@ -25,7 +25,6 @@
"intelephense.format.braces": "k&r", "intelephense.format.braces": "k&r",
"continue.enableTabAutocomplete": true, "continue.enableTabAutocomplete": true,
"intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": true, "intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": true,
"diffEditor.renderSideBySide": false,
"diffEditor.hideUnchangedRegions.enabled": true, "diffEditor.hideUnchangedRegions.enabled": true,
"nix.formatterPath": "nixfmt", "nix.formatterPath": "nixfmt",
"explorer.confirmDelete": false, "explorer.confirmDelete": false,