bin
This commit is contained in:
parent
aad8bcdfd5
commit
848a1b6ad3
19
user/bin.nix
Normal file
19
user/bin.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{ config, pkgs, homeDirectory, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
deps = {
|
||||||
|
bell = [ pkgs.pipewire pkgs.libnotify ];
|
||||||
|
nsxiv-rifle = [ pkgs.nsxiv ];
|
||||||
|
screenshot = [ pkgs.maim pkgs.xclip ];
|
||||||
|
};
|
||||||
|
mkln = x: config.lib.file.mkOutOfStoreSymlink "${homeDirectory}/.local/nixos/user/bin/${x}";
|
||||||
|
in {
|
||||||
|
home.file = builtins.listToAttrs (map
|
||||||
|
(x: {
|
||||||
|
name = ".local/bin/${x}";
|
||||||
|
value = { source = mkln x; };
|
||||||
|
})
|
||||||
|
(builtins.attrNames (builtins.readDir ./bin))
|
||||||
|
);
|
||||||
|
home.packages = pkgs.lib.lists.flatten (builtins.attrValues deps);
|
||||||
|
}
|
||||||
7
user/bin/bell
Executable file
7
user/bin/bell
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
WAV="$XDG_DATA_HOME/bell.wav"
|
||||||
|
if [ -f $WAV ] && [ $(pgrep pw-play | wc -l) -le 10 ]; then
|
||||||
|
pw-play --volume 0.5 "$WAV" &
|
||||||
|
else
|
||||||
|
notify-send "Bell"
|
||||||
|
fi
|
||||||
36
user/bin/nsxiv-rifle
Executable file
36
user/bin/nsxiv-rifle
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
TMPDIR="${TMPDIR:-/tmp}"
|
||||||
|
tmp="$TMPDIR/nsxiv_rifle_$$"
|
||||||
|
|
||||||
|
is_img_extension() {
|
||||||
|
grep -iE '\.(jpe?g|png|gif|svg|webp|tiff|heif|avif|ico|bmp)$'
|
||||||
|
}
|
||||||
|
|
||||||
|
listfiles() {
|
||||||
|
find -L "///${1%/*}" -maxdepth 1 -type f -print |
|
||||||
|
is_img_extension | sort -V | tee "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
open_img() {
|
||||||
|
# only go through listfiles() if the file has a valid img extension
|
||||||
|
if echo "$1" | is_img_extension >/dev/null 2>&1; then
|
||||||
|
trap 'rm -f $tmp' EXIT
|
||||||
|
count="$(listfiles "$1" | grep -nF "$1")"
|
||||||
|
fi
|
||||||
|
if [ -n "$count" ]; then
|
||||||
|
nsxiv -i -n "${count%%:*}" -a -p -- < "$tmp"
|
||||||
|
else
|
||||||
|
# fallback incase file didn't have a valid extension, or we couldn't
|
||||||
|
# find it inside the list
|
||||||
|
nsxiv -a -p -- "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "$1" = '--' ] && shift
|
||||||
|
case "$1" in
|
||||||
|
"") echo "Usage: ${0##*/} PICTURES" >&2; exit 1 ;;
|
||||||
|
/*) open_img "$1" ;;
|
||||||
|
"~"/*) open_img "$HOME/${1#"~"/}" ;;
|
||||||
|
*) open_img "$PWD/$1" ;;
|
||||||
|
esac
|
||||||
2
user/bin/screenshot
Executable file
2
user/bin/screenshot
Executable file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
maim -su -f jpg -m 10 | xclip -selection clipboard -t image/png
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
imports = [
|
imports = [
|
||||||
./xdg.nix
|
./xdg.nix
|
||||||
./theme.nix
|
./theme.nix
|
||||||
|
./bin.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
home.username = username;
|
home.username = username;
|
||||||
|
|
@ -57,9 +58,6 @@
|
||||||
killall
|
killall
|
||||||
file
|
file
|
||||||
|
|
||||||
alsa-utils
|
|
||||||
libnotify
|
|
||||||
|
|
||||||
(python311.withPackages (python-pkgs: [
|
(python311.withPackages (python-pkgs: [
|
||||||
python-pkgs.pwntools
|
python-pkgs.pwntools
|
||||||
# python-pkgs.angr
|
# python-pkgs.angr
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue