nixfiles/config/profiles/graphical/scripts.nix

88 lines
3 KiB
Nix
Raw Normal View History

2024-04-03 15:35:54 +02:00
{ pkgs, inputs, ... }: {
imports = [
inputs.home-manager.nixosModules.home-manager
];
home-manager.users.emily.home.file.".local/bin/hypr/colorpicker.sh" = {
enable = true;
executable = true;
text = ''
#!/${pkgs.bash}/bin/bash
color=$(${pkgs.grim}/bin/grim -g "`${pkgs.slurp}/bin/slurp -b 20262C00 -p`" -t ppm - | \
${pkgs.imagemagick_light}/bin/convert - -format '%[pixel:p{0,0}]' txt:- | \
${pkgs.coreutils}/bin/tail -n1 | ${pkgs.coreutils}/bin/cut -d' ' -f4)
image=/tmp/''${color}.png
main() {
if [[ "$color" ]]; then
${pkgs.coreutils}/bin/echo $color | ${pkgs.coreutils}/bin/tr -d "\n" | ${pkgs.wl-clipboard}/bin/wl-copy
${pkgs.imagemagick_light}/bin/convert -size 48x48 xc:"$color" ''${image}
${pkgs.libnotify}/bin/notify-send -h string:x-canonical-private-synchronous:sys-notify-picker -u low -i ''${image} "$color, copied to clipboard."
fi
}
main
'';
};
home-manager.users.emily.home.file.".local/bin/hypr/screenshot.sh" = let
cu = "${pkgs.coreutils}/bin";
grim = "${pkgs.grim}/bin/grim";
notify-send = "${pkgs.libnotify}/bin/notify-send";
paplay = "${pkgs.pulseaudio}/bin/paplay";
slurp = "${pkgs.slurp}/bin/slurp";
2024-05-11 16:02:39 +02:00
imv = "${pkgs.imv}/bin/imv";
2024-04-03 15:35:54 +02:00
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
in {
enable = true;
executable = true;
text = ''
#!/${pkgs.bash}/bin/bash
iDIR="$HOME/.config/mako-icons"
time=`${cu}/date +%Y-%m-%d-%H-%M-%S`
dir="$HOME/Pictures/screenshots"
file="''${time}.png"
notify_cmd_shot="${notify-send} -h string:x-canonical-private-synchronous:sys-notify-shot -u low -i ''${iDIR}/picture.png"
notify_view () {
''${notify_cmd_shot} "Copied to clipboard."
${paplay} /usr/share/sounds/freedesktop/stereo/screen-capture.oga &>/dev/null &
2024-05-11 16:02:39 +02:00
${imv} "''${dir}/$file"
2024-04-03 15:35:54 +02:00
if [[ -e "$dir/$file" ]]; then
''${notify_cmd_shot} "Screenshot Saved."
else
''${notify_cmd_shot} "Screenshot Deleted."
fi
}
countdown () {
for sec in `${cu}/seq $1 -1 1`; do
${notify-send} -h string:x-canonical-private-synchronous:sys-notify-count -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec"
${cu}/sleep 1
done
}
shotnow () {
cd ''${dir} && ${cu}/sleep 0.5 && ${grim} - | ${cu}/tee "$file" | ${wl-copy}
notify_view
}
shotarea () {
cd ''${dir} && ${grim} -g "$(${slurp} -b 20262CCC -c B4A1DBff -s B4A1DB0D -w 2 && ${cu}/sleep 0.3)" - | ${cu}/tee "$file" | ${wl-copy}
notify_view
}
if [[ ! -d "$dir" ]]; then
${cu}/mkdir -p "$dir"
fi
if [[ "$1" == "--now" ]]; then
shotnow
elif [[ "$1" == "--in5" ]]; then
countdown '5'
shotnow
elif [[ "$1" == "--in10" ]]; then
countdown '10'
shotnow
elif [[ "$1" == "--area" ]]; then
shotarea
else
echo -e "Available Options : --now --in5 --in10 --area"
fi
exit 0
'';
};
}