feat: refactored Hyprshot to work with sway
This commit is contained in:
parent
07eeebb85f
commit
f792aac8a2
1 changed files with 7 additions and 9 deletions
|
@ -6,9 +6,9 @@ AVAILABLE_MODES=(output window region)
|
|||
|
||||
function Help() {
|
||||
cat <<EOF
|
||||
Usage: hyprshot [options ..] -m [mode] -- [command]
|
||||
Usage: sway-screenshot [options ..] -m [mode] -- [command]
|
||||
|
||||
Hyprshot is an utility to easily take screenshot in Hyprland using your mouse.
|
||||
sway-screenshot is an utility to easily take screenshot in swaywm using your mouse.
|
||||
|
||||
It allows taking screenshots of windows, regions and monitors which are saved to a folder of your choosing and copied to your clipboard.
|
||||
|
||||
|
@ -20,7 +20,7 @@ Options:
|
|||
-d, --debug print debug information
|
||||
-s, --silent don't send notification when screenshot is saved
|
||||
--clipboard-only copy screenshot to clipboard and don't save image in disk
|
||||
-- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage
|
||||
-- [command] open screenshot with a command of your choosing. e.g. sway-screenshot -m window -- mirage
|
||||
|
||||
Modes:
|
||||
output take screenshot of an entire monitor
|
||||
|
@ -91,13 +91,11 @@ function grab_region() {
|
|||
}
|
||||
|
||||
function grab_window() {
|
||||
local monitors=`hyprctl -j monitors`
|
||||
local clients=`hyprctl -j clients | jq -r '[.[] | select(.workspace.id | contains('$(echo $monitors | jq -r 'map(.activeWorkspace.id) | join(",")')'))]'`
|
||||
Print "Monitors: %s\n" "$monitors"
|
||||
local clients=`swaymsg -t get_tree | jq -r '[.. | ((.nodes? // empty) + (.floating_nodes? // empty))[] | select(.visible and .pid)]'`
|
||||
Print "Clients: %s\n" "$clients"
|
||||
# Generate boxes for each visible window and send that to slurp
|
||||
# through stdin
|
||||
local boxes="$(echo $clients | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1]) \(.title)"')"
|
||||
local boxes="$(echo $clients | jq -r '.[] | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height) \(.name)"')"
|
||||
Print "Boxes:\n%s\n" "$boxes"
|
||||
slurp -r <<< "$boxes"
|
||||
}
|
||||
|
@ -155,8 +153,8 @@ fi
|
|||
CLIPBOARD=0
|
||||
DEBUG=0
|
||||
SILENT=0
|
||||
FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')"
|
||||
[ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR}
|
||||
FILENAME="$(date +'%Y-%m-%d-%H%M%S_sway-screenshot.png')"
|
||||
[ -z "$SWAY_SCREENSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${SWAY_SCREENSHOT_DIR}
|
||||
|
||||
args $0 "$@"
|
||||
|
Loading…
Add table
Reference in a new issue