Enable file-overwriting in screenshot script
This commit is contained in:
parent
011d11463b
commit
d9bf5d121b
|
@ -92,15 +92,13 @@ def take_subcommand(args):
|
|||
case "light":
|
||||
add_drop_shadow(save_path, save_path, 'white', 'black')
|
||||
case "dark":
|
||||
add_drop_shadow(save_path, save_path, '#515e6e', 'black')
|
||||
add_drop_shadow(save_path, save_path, '#d3869b', 'black')
|
||||
|
||||
if args.clipboard:
|
||||
copy_to_clipboard(save_path)
|
||||
|
||||
if args.file is not None and not os.path.isfile(args.file):
|
||||
if args.file is not None:
|
||||
shutil.copyfile(save_path, args.file)
|
||||
elif args.file is not None:
|
||||
raise Exception(f"Refusing to overwrite {args.file}")
|
||||
|
||||
# Provides a drawing editor for the latest image
|
||||
def markup_latest(args):
|
||||
|
@ -162,11 +160,11 @@ take_subcmd.add_argument(
|
|||
|
||||
# Different possible screenshot regions
|
||||
region = take_subcmd.add_subparsers(dest='region', required=True);
|
||||
region.add_parser(
|
||||
full = region.add_parser(
|
||||
'full', help='Take a screenshot of the entire screen');
|
||||
exact = region.add_parser(
|
||||
'exact', help="Exact dimensions of screenshot: 'x,y width,height'");
|
||||
region.add_parser(
|
||||
select = region.add_parser(
|
||||
'select', help="Use `slurp` to select a region with your mouse");
|
||||
exact.add_argument(
|
||||
'dimensions',
|
||||
|
@ -175,9 +173,16 @@ exact.add_argument(
|
|||
help="Exact dimensions of screenshot: 'x,y width,height'"
|
||||
);
|
||||
|
||||
take_subcmd.add_argument(
|
||||
"file", nargs='?',
|
||||
type=Path,
|
||||
full.add_argument(
|
||||
"file", nargs='?', type=Path,
|
||||
help="Save the screenshot to this file name"
|
||||
);
|
||||
exact.add_argument(
|
||||
"file", nargs='?', type=Path,
|
||||
help="Save the screenshot to this file name"
|
||||
);
|
||||
select.add_argument(
|
||||
"file", nargs='?', type=Path,
|
||||
help="Save the screenshot to this file name"
|
||||
);
|
||||
# Edit ====
|
||||
|
@ -186,7 +191,7 @@ edit_subcmd = subcommands.add_parser(
|
|||
edit_subcmd.add_argument(
|
||||
'-r', '--resize',
|
||||
type=int,
|
||||
metavar="<pixels>",
|
||||
metavar="<percent>",
|
||||
help='Resize the latest screenshot instead of taking a new one',
|
||||
);
|
||||
edit_subcmd.add_argument(
|
||||
|
@ -197,9 +202,9 @@ edit_subcmd.add_argument(
|
|||
);
|
||||
edit_subcmd.add_argument(
|
||||
'-d', '--drop-shadow',
|
||||
type=int,
|
||||
metavar="<pixels>",
|
||||
help='Save the screenshot with a drop shadow of x pixels',
|
||||
action='store',
|
||||
choices=['light', 'dark'],
|
||||
help='Apply a drop shadow with a light/dark background',
|
||||
);
|
||||
edit_subcmd.add_argument(
|
||||
'-e', '--extension',
|
||||
|
|
66
sway/config
66
sway/config
|
@ -49,14 +49,10 @@ set $menu fuzzel -fmonospace:size=14 -l10 -w40 \
|
|||
# Sound effects and additional features
|
||||
set $volume_command ~/.config/sway/pulse_audio_volume.sh
|
||||
set $volume_change_sound ~/.config/sway/volume_change_sound.mp3
|
||||
set $screenshot_sound ffplay -nodisp -autoexit -v error ~/.config/sway/screenshot_sound.mp3
|
||||
|
||||
set $screenshot_sound ffplay -nodisp -autoexit -v error \
|
||||
~/.config/sway/screenshot_sound.mp3
|
||||
|
||||
# TODO: Unique sensible name
|
||||
set $original_path ~/Desktop/shrink_screenshot_out.png
|
||||
set $compress_path ~/Desktop/shrink_screenshot_out.webp
|
||||
set $shrink_path ~/Desktop/shrink_screenshot_out.png
|
||||
# Duplicate screenshot path, for quick uploads
|
||||
set $screenshot_tmp /dev/shm/screenshot_shm.png
|
||||
|
||||
#╔─────────────────────────────────────────────────────────────────────────────╗
|
||||
#│ Pαηεs αηd cδηταiηεrs |
|
||||
|
@ -299,30 +295,30 @@ bindsym $mod2+Escape exec ~/.config/sway/sway_exit.sh
|
|||
|
||||
# Screenshots ====
|
||||
bindsym $mod2+6 mode "screenshots"
|
||||
bindsym $mod2+5 mode "screenshots"; exec ~/.configs_pointer/bin/screenshot_wayland.sh area --clipboard && $screenshot_sound
|
||||
bindsym $mod2+4 mode "screenshots"; exec ~/.configs_pointer/bin/screenshot_wayland.sh \
|
||||
-c -d 40 -s "$(~/.config/sway/window_dimensions.sh)" $original_path && $screenshot_sound
|
||||
bindsym $mod2+5 mode "screenshots"; exec ~/.configs_pointer/bin/screenshot_wayland.py take -c select $screenshot_tmp && $screenshot_sound
|
||||
bindsym $mod2+4 mode "screenshots"; exec ~/.configs_pointer/bin/screenshot_wayland.py \
|
||||
take -c -d "$(colo.sh -t)" exact "$(~/.config/sway/window_dimensions.py)" $screenshot_tmp && $screenshot_sound
|
||||
|
||||
mode "screenshots" {
|
||||
# Screenshooting in processing "steps"
|
||||
# 1. Get screenshot
|
||||
bindsym a exec ~/.configs_pointer/bin/screenshot_wayland.sh area --clipboard \
|
||||
$original_path && $screenshot_sound
|
||||
bindsym f exec ~/.configs_pointer/bin/screenshot_wayland.sh full --clipboard \
|
||||
$original_path && $screenshot_sound
|
||||
bindsym s mode "default"; exec ~/.configs_pointer/bin/screenshot_wayland.sh markup
|
||||
bindsym a exec ~/.configs_pointer/bin/screenshot_wayland.py take -c select \
|
||||
$screenshot_tmp && $screenshot_sound
|
||||
bindsym f exec ~/.configs_pointer/bin/screenshot_wayland.py take -c full \
|
||||
$screenshot_tmp && $screenshot_sound
|
||||
bindsym m mode "default"; exec ~/.configs_pointer/bin/screenshot_wayland.py markup
|
||||
|
||||
# 2. Downsize the screenshot, since 4k is too big
|
||||
bindsym 1 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '10%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 2 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '20%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 3 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '30%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 4 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '40%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 5 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '50%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 6 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '60%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 7 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '70%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 8 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '80%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 9 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '90%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 0 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '100%' --clipboard --extension png $shrink_path && $screenshot_sound
|
||||
bindsym 1 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '10%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 2 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '20%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 3 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '30%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 4 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '40%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 5 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '50%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 6 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '60%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 7 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '70%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 8 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '80%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 9 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '90%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
bindsym 0 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '100%' --clipboard --extension png $screenshot_tmp && $screenshot_sound
|
||||
|
||||
# OR compress image
|
||||
bindsym space mode "shrink_screenshots"
|
||||
|
@ -337,16 +333,16 @@ mode "screenshots" {
|
|||
|
||||
mode "shrink_screenshots" {
|
||||
# 2. Compress the screenshot, hard
|
||||
bindsym 1 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '10%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 2 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '20%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 3 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '30%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 4 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '40%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 5 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '50%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 6 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '60%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 7 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '70%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 8 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '80%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 9 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '90%' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 0 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '100' --clipboard --extension webp $compress_path && $screenshot_sound
|
||||
bindsym 1 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '10%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 2 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '20%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 3 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '30%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 4 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '40%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 5 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '50%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 6 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '60%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 7 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '70%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 8 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '80%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 9 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '90%' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
bindsym 0 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '100' --clipboard --extension webp $screenshot_tmp && $screenshot_sound
|
||||
|
||||
bindsym space mode "screenshots"
|
||||
|
||||
|
|
Loading…
Reference in a new issue