Browse Source

Switch to dulcepan sway screenshot tool

master
Arti Zirk 2 days ago
parent
commit
09883c3d40
  1. 25
      .bin/wscreenshot.py
  2. 47
      .config/dulcepan.cfg

25
.bin/wscreenshot.py

@ -1,4 +1,18 @@ @@ -1,4 +1,18 @@
#!/usr/bin/env python3
"""
Sway screenshot tool. Saved screenshots are also added to GTK recents list for easy access.
Uses following tools
* grim
* slurp
* https://codeberg.org/vyivel/dulcepan
* jq
Region selection uses dulcepan. It works by first freezing the screen so that popups sway visible.
Then it allows selection of the region you want to screenshot.
"""
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
@ -28,16 +42,7 @@ else: @@ -28,16 +42,7 @@ else:
sys.exit(0)
elif sys.argv[1] == '--region':
outputs = run(['swaymsg', '-t', 'get_outputs'], check=True, capture_output=True)
for output in json.loads(outputs.stdout):
if not output.get("focused"):
continue
image = Popen(["grim", "-o", f"{output.get('name')}", '-'], stdout=PIPE)
viewer = Popen(['swayimg', '-f', '-o', f'{output.get("name")}','-'], stdin=image.stdout)
image_viewers.append(viewer)
region = run('slurp', check=True, capture_output=True)
run(["grim", '-g', '-', file_name], check=True, input=region.stdout)
run(["dulcepan", "-C", "-o", file_name], check=True)
elif sys.argv[1] == '--window':
tree = run(['swaymsg', '-t', 'get_tree'], check=True, capture_output=True)

47
.config/dulcepan.cfg

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
# An example configuration.
# RRGGBB or RRGGBBAA
unselected-color = ffffff40
selected-color = 00000000
#border-color = ffffff
border-color = 000000
#border-secondary-color = 000000
border-secondary-color = ffffff
# 0 to disable borders
border-size = 2
# Border gradient type:
# - none: only the primary border color is used
# - linear: uses a linear gradient relative to the selection
# - loop: uses a repeated linear gradient
border-gradient = none
# For "linear" gradient mode
# Counterclockwise, in degrees
gradient-angle = 45
# For "loop" gradient mode
# The distance between gradient stops
loop-step = 100
# For "linear" and "loop" gradient modes
# In milliseconds, 0 to disable animation
# With "linear" mode: the time it takes for the pattern to make one full turn
# With "loop" mode: the time it takes for the pattern to move by double the loop step
animation-duration = 1000
# If true, dulcepan will save immediately when interactive selection is stopped
# or when a whole output is selected with a mouse button.
quick-select = true
# If true, dulcepan will remember selection between runs.
# The state is stored at $XDG_CACHE_HOME/dulcepan.
persistence = false
# PNG (zlib) compression level, 0-9
png-compression = 6
# Key bindings
quit-key = Escape
save-key = Space
Loading…
Cancel
Save