What a clusterfuck
This commit is contained in:
parent
91f88b8bb2
commit
f29273be22
221 changed files with 779 additions and 956 deletions
64
modules/home/sway/swayshot/default.nix
Normal file
64
modules/home/sway/swayshot/default.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{ pkgs, outputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./swappy
|
||||
];
|
||||
|
||||
home.packages = let
|
||||
swayShot = pkgs.writeScriptBin "swayshot" ''
|
||||
# Swappy
|
||||
handle_swappy() {
|
||||
# Create an imv window to act as a static screen
|
||||
grim -t jpeg -q 90 - | imv -w "GlobalShot" - & imv_pid=$!
|
||||
|
||||
# Capture the screenshot of the selected area and save to a temporary file
|
||||
selected_area=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"'\
|
||||
| XCURSOR_SIZE=40 slurp -w ${outputs.look.border.string} -c ${outputs.look.colors.prime} -B 00000066 -b 00000099)
|
||||
temp_file=$(mktemp -u).png
|
||||
grim -g "$selected_area" "$temp_file"
|
||||
|
||||
# Kill the imv window
|
||||
kill $imv_pid
|
||||
|
||||
# Copy the screenshot to the clipboard
|
||||
swappy -f - < "$temp_file"
|
||||
|
||||
# Clean up the temporary file
|
||||
rm "$temp_file"
|
||||
}
|
||||
|
||||
# Screen
|
||||
handle_screen() {
|
||||
# Take a screenshot and save it to the temporary file
|
||||
temp_file=$(mktemp -u).png
|
||||
grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') "$temp_file"
|
||||
|
||||
# Check if the screenshot was successfully taken
|
||||
if [ $? -eq 0 ]; then
|
||||
# Copy the screenshot to the clipboard
|
||||
wl-copy < "$temp_file"
|
||||
|
||||
# Show a notification with the screenshot
|
||||
notify-send -i "$temp_file" "Current screen copied."
|
||||
|
||||
# Remove the temporary file
|
||||
rm "$temp_file"
|
||||
else
|
||||
# If the screenshot capture failed, show an error notification
|
||||
notify-send "Error: Unable to capture screenshot."
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for command-line arguments
|
||||
if [ "$1" == "--swappy" ]; then
|
||||
handle_swappy
|
||||
elif [ "$1" == "--screen" ]; then
|
||||
handle_screen
|
||||
else
|
||||
echo "Please use the arguments --swappy or --screen."
|
||||
fi
|
||||
'';
|
||||
in with pkgs; [
|
||||
swayShot
|
||||
];
|
||||
}
|
15
modules/home/sway/swayshot/swappy/default.nix
Normal file
15
modules/home/sway/swayshot/swappy/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
home = {
|
||||
packages = with pkgs; [
|
||||
swappy
|
||||
];
|
||||
file = {
|
||||
".config/swappy/config".text = ''
|
||||
[Default]
|
||||
early_exit=true
|
||||
save_dir=$HOME/Pictures/Screenshots
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue