Screenshot: Update sway config

This commit is contained in:
Akemi Izuko 2022-11-23 22:41:22 -07:00
parent 3338a98f0d
commit 6c2a245326
No known key found for this signature in database
GPG key ID: 905D444F6A5E4BE4
2 changed files with 41 additions and 35 deletions

View file

@ -118,12 +118,6 @@ def take_subcommand(args):
case _: case _:
raise Exception(f"Region '{args.region}' not recognized") raise Exception(f"Region '{args.region}' not recognized")
match args.drop_shadow:
case "light":
add_drop_shadow(save_path, save_path, DS_BG_LIGHT, DS_SHADOW_LIGHT)
case "dark":
add_drop_shadow(save_path, save_path, DS_BG_DARK, DS_SHADOW_DARK)
if args.clipboard: if args.clipboard:
copy_to_clipboard(save_path) copy_to_clipboard(save_path)
@ -135,6 +129,9 @@ def edit_subcommand(args):
ext = args.extension if args.extension else 'avif' ext = args.extension if args.extension else 'avif'
og_path, edit_path = get_edit_path(ext) og_path, edit_path = get_edit_path(ext)
if args.overwrite:
edit_path = og_path
# Drop shadow # Drop shadow
match args.drop_shadow: match args.drop_shadow:
case "light": case "light":
@ -215,17 +212,6 @@ subcommands = parser.add_subparsers(dest='subcommand', required=True);
# Take ==== # Take ====
take_subcmd = subcommands.add_parser( take_subcmd = subcommands.add_parser(
"take", help="Takes a screenshot. (Default is full screen)"); "take", help="Takes a screenshot. (Default is full screen)");
take_subcmd.add_argument(
'-c', '--clipboard',
action='store_true',
help='Save the screenshot to your clipboard',
);
take_subcmd.add_argument(
'-d', '--drop-shadow',
action='store',
choices=['light', 'dark'],
help='Apply a drop shadow to the final image with a light/dark background',
);
# Different possible screenshot regions # Different possible screenshot regions
region = take_subcmd.add_subparsers(dest='region', required=True); region = take_subcmd.add_subparsers(dest='region', required=True);
@ -242,6 +228,22 @@ exact.add_argument(
help="Exact dimensions of screenshot: 'x,y width,height'" help="Exact dimensions of screenshot: 'x,y width,height'"
); );
full.add_argument(
'-c', '--clipboard',
action='store_true',
help='Save the screenshot to your clipboard',
);
exact.add_argument(
'-c', '--clipboard',
action='store_true',
help='Save the screenshot to your clipboard',
);
select.add_argument(
'-c', '--clipboard',
action='store_true',
help='Save the screenshot to your clipboard',
);
full.add_argument( full.add_argument(
"file", nargs='?', type=Path, "file", nargs='?', type=Path,
help="Save the screenshot to this file name" help="Save the screenshot to this file name"
@ -286,6 +288,11 @@ edit_subcmd.add_argument(
metavar="<ext>", metavar="<ext>",
help='Change image extension and image type saved', help='Change image extension and image type saved',
); );
edit_subcmd.add_argument(
'--overwrite',
action='store_true',
help='Overwrite original image with the edited image',
);
edit_subcmd.add_argument( edit_subcmd.add_argument(
"file", nargs='?', type=Path, "file", nargs='?', type=Path,
help="Save the screenshot to this file name" help="Save the screenshot to this file name"

View file

@ -53,6 +53,7 @@ set $screenshot_sound ffplay -nodisp -autoexit -v error ~/.config/sway/screensho
# Duplicate screenshot path, for quick uploads # Duplicate screenshot path, for quick uploads
set $screenshot_tmp /dev/shm/screenshot_shm.png set $screenshot_tmp /dev/shm/screenshot_shm.png
set $screenshot_script ~/.configs_pointer/bin/screenshot_wayland.py
#╔─────────────────────────────────────────────────────────────────────────────╗ #╔─────────────────────────────────────────────────────────────────────────────╗
#│ Pαηεs αηd cδηταiηεrs | #│ Pαηεs αηd cδηταiηεrs |
@ -295,30 +296,28 @@ bindsym $mod2+Escape exec ~/.config/sway/sway_exit.sh
# Screenshots ==== # Screenshots ====
bindsym $mod2+6 mode "screenshots" bindsym $mod2+6 mode "screenshots"
bindsym $mod2+5 mode "screenshots"; exec ~/.configs_pointer/bin/screenshot_wayland.py take -c select $screenshot_tmp && $screenshot_sound bindsym $mod2+5 mode "screenshots"; exec $screenshot_script take select -c $screenshot_tmp && $screenshot_sound
bindsym $mod2+4 mode "screenshots"; exec ~/.configs_pointer/bin/screenshot_wayland.py \ bindsym $mod2+4 mode "screenshots"; exec $screenshot_script take exact "$(~/.config/sway/window_dimensions.py)" && \
take -c -d "$(colo.sh -t)" exact "$(~/.config/sway/window_dimensions.py)" $screenshot_tmp && $screenshot_sound $screenshot_script edit -c --overwrite -d "$(colo.sh -t)" -e png $screenshot_tmp && $screenshot_sound
mode "screenshots" { mode "screenshots" {
# Screenshooting in processing "steps" # Screenshooting in processing "steps"
# 1. Get screenshot # 1. Get screenshot
bindsym a exec ~/.configs_pointer/bin/screenshot_wayland.py take -c select \ bindsym a exec $screenshot_script take select -c $screenshot_tmp && $screenshot_sound
$screenshot_tmp && $screenshot_sound bindsym f exec $screenshot_script take full -c $screenshot_tmp && $screenshot_sound
bindsym f exec ~/.configs_pointer/bin/screenshot_wayland.py take -c full \ bindsym m mode "default"; exec $screenshot_script markup
$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 # 2. Downsize the screenshot, since 4k is too big
bindsym 1 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '10%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 1 exec $screenshot_script edit -c -e png r '10%' $screenshot_tmp && $screenshot_sound
bindsym 2 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '20%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 2 exec $screenshot_script edit -c -e png r '20%' $screenshot_tmp && $screenshot_sound
bindsym 3 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '30%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 3 exec $screenshot_script edit -c -e png r '30%' $screenshot_tmp && $screenshot_sound
bindsym 4 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '40%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 4 exec $screenshot_script edit -c -e png r '40%' $screenshot_tmp && $screenshot_sound
bindsym 5 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '50%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 5 exec $screenshot_script edit -c -e png r '50%' $screenshot_tmp && $screenshot_sound
bindsym 6 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '60%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 6 exec $screenshot_script edit -c -e png r '60%' $screenshot_tmp && $screenshot_sound
bindsym 7 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '70%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 7 exec $screenshot_script edit -c -e png r '70%' $screenshot_tmp && $screenshot_sound
bindsym 8 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '80%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 8 exec $screenshot_script edit -c -e png r '80%' $screenshot_tmp && $screenshot_sound
bindsym 9 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '90%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 9 exec $screenshot_script edit -c -e png r '90%' $screenshot_tmp && $screenshot_sound
bindsym 0 exec ~/.configs_pointer/bin/screenshot_wayland.sh --resize '100%' --clipboard --extension png $screenshot_tmp && $screenshot_sound bindsym 0 exec $screenshot_script edit -c -e png r '100%' $screenshot_tmp && $screenshot_sound
# OR compress image # OR compress image
bindsym space mode "shrink_screenshots" bindsym space mode "shrink_screenshots"