Convert screenshot.sh to nix's writeShellApplication
This commit is contained in:
parent
c6651a7eb6
commit
88c6138463
5 changed files with 41 additions and 40 deletions
|
@ -1,19 +1,9 @@
|
||||||
{
|
{ pkgs, config, inputs, ... }: {
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
home = {
|
home = {
|
||||||
username = "avery";
|
username = "avery";
|
||||||
homeDirectory = "/home/avery";
|
homeDirectory = "/home/avery";
|
||||||
stateVersion = "24.05";
|
stateVersion = "24.05";
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [ python3 rclone xdg-utils ];
|
||||||
python3
|
|
||||||
rclone
|
|
||||||
xdg-user-dirs
|
|
||||||
xdg-utils
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
obs-studio
|
obs-studio
|
||||||
picard
|
picard
|
||||||
protonup-qt
|
protonup-qt
|
||||||
grim
|
|
||||||
libsForQt5.ark
|
libsForQt5.ark
|
||||||
libsForQt5.dolphin
|
libsForQt5.dolphin
|
||||||
libsForQt5.dolphin-plugins
|
libsForQt5.dolphin-plugins
|
||||||
|
@ -34,12 +33,12 @@
|
||||||
playerctl
|
playerctl
|
||||||
qbittorrent
|
qbittorrent
|
||||||
r2modman
|
r2modman
|
||||||
slurp
|
|
||||||
swww
|
swww
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
(import ./scripts/colorpicker.nix { inherit pkgs; })
|
(import ./scripts/colorpicker.nix { inherit pkgs; })
|
||||||
(import ./scripts/currently-playing.nix { inherit pkgs; })
|
(import ./scripts/currently-playing.nix { inherit pkgs; })
|
||||||
(import ./scripts/change-wallpaper.nix { inherit pkgs; })
|
(import ./scripts/change-wallpaper.nix { inherit pkgs; })
|
||||||
|
(import ./scripts/screenshot.nix { inherit pkgs; })
|
||||||
(pkgs.buildEnv {
|
(pkgs.buildEnv {
|
||||||
name = "desktop-scripts";
|
name = "desktop-scripts";
|
||||||
paths = [ ./scripts_legacy ];
|
paths = [ ./scripts_legacy ];
|
||||||
|
|
|
@ -82,8 +82,8 @@
|
||||||
"SUPER SHIFT, 9, movetoworkspace, 9"
|
"SUPER SHIFT, 9, movetoworkspace, 9"
|
||||||
"SUPER SHIFT, 0, movetoworkspace, 10"
|
"SUPER SHIFT, 0, movetoworkspace, 10"
|
||||||
|
|
||||||
"SUPER, S, exec, screenshot.sh full"
|
"SUPER, S, exec, screenshot full"
|
||||||
"SUPER + SHIFT, S, exec, screenshot.sh section"
|
"SUPER + SHIFT, S, exec, screenshot section"
|
||||||
|
|
||||||
"MOD3, C, exec, colorpicker"
|
"MOD3, C, exec, colorpicker"
|
||||||
|
|
||||||
|
|
36
hosts/totsugeki/desktop/scripts/screenshot.nix
Normal file
36
hosts/totsugeki/desktop/scripts/screenshot.nix
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{ pkgs }:
|
||||||
|
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "screenshot";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
dunst
|
||||||
|
grim
|
||||||
|
libjxl
|
||||||
|
slurp
|
||||||
|
wl-clipboard
|
||||||
|
xdg-user-dirs
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
usage() {
|
||||||
|
echo "Usage: screenshot { full | section }"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
test -n 1 || usage
|
||||||
|
|
||||||
|
FILE_NAME=$(date +'Screenshot_%Y%m%d_%H%M%S')
|
||||||
|
TEMPORARY_PATH="/tmp/$FILE_NAME.png"
|
||||||
|
SCREENSHOT_PATH="$(xdg-user-dir PICTURES)/$FILE_NAME.jxl"
|
||||||
|
if [ "$1" == "full" ]; then
|
||||||
|
grim "$TEMPORARY_PATH"
|
||||||
|
elif [ "$1" == "section" ]; then
|
||||||
|
grim -g "$(slurp -b '#000000aa' -w 0)" "$TEMPORARY_PATH"
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
wl-copy < "$TEMPORARY_PATH"
|
||||||
|
cjxl "$TEMPORARY_PATH" "$SCREENSHOT_PATH"
|
||||||
|
dunstify --raw_icon="$TEMPORARY_PATH" "Captura de pantalla realizada" "Guardada como $FILE_NAME.jxl"
|
||||||
|
rm "$TEMPORARY_PATH"
|
||||||
|
'';
|
||||||
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
missing_params() {
|
|
||||||
echo "Missing parameters, usage: screenshot.sh <type>"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
test -n 1 || missing_params
|
|
||||||
|
|
||||||
FILE_NAME=$(date +'Screenshot_%Y%m%d_%H%M%S')
|
|
||||||
TEMPORARY_PATH="/tmp/$FILE_NAME.png"
|
|
||||||
SCREENSHOT_PATH=$(xdg-user-dir PICTURES)/$FILE_NAME.jxl
|
|
||||||
|
|
||||||
if [ $1 == "full" ]; then
|
|
||||||
grim $TEMPORARY_PATH
|
|
||||||
elif [ $1 == "section" ]; then
|
|
||||||
grim -g "$(slurp -b '#000000aa' -w 0)" $TEMPORARY_PATH
|
|
||||||
fi
|
|
||||||
if [ $? == 0 ]; then
|
|
||||||
wl-copy < $TEMPORARY_PATH
|
|
||||||
cjxl $TEMPORARY_PATH $SCREENSHOT_PATH
|
|
||||||
dunstify --raw_icon=$TEMPORARY_PATH "Captura de pantalla realizada" "Guardada como $FILE_NAME.jxl"
|
|
||||||
rm $TEMPORARY_PATH
|
|
||||||
fi
|
|
Loading…
Add table
Add a link
Reference in a new issue