New backup 2026-03-03 11:23:26

This commit is contained in:
Penelope Gwen 2026-03-03 11:23:26 -08:00
parent 9944110bd6
commit 68d47f30a0
4 changed files with 170 additions and 9 deletions

View file

@ -4,13 +4,9 @@ bindsym {
$mod+grave workspace 0: $mod+grave workspace 0:
$mod+Shift+grave move container to workspace 0: $mod+Shift+grave move container to workspace 0:
#profile keybinds #profile keybinds
# $mod+p exec "sp-profiles Personal"
$mod+p exec "sdu profile switch to Penelope" $mod+p exec "sdu profile switch to Penelope"
# $mod+Bracketleft exec "sp-profiles Development"
$mod+Bracketleft exec "sdu profile switch to Development" $mod+Bracketleft exec "sdu profile switch to Development"
# $mod+Bracketright exec "sp-profiles School"
$mod+Bracketright exec "sdu profile switch to School" $mod+Bracketright exec "sdu profile switch to School"
# $mod+Backslash exec "sp-profiles Work"
$mod+Backslash exec "sdu profile switch to Work" $mod+Backslash exec "sdu profile switch to Work"
#workspace cycle keybinds #workspace cycle keybinds
$mod+Tab workspace next $mod+Tab workspace next
@ -19,9 +15,9 @@ bindsym {
## $mod+Shift+r exec sp-rename ## $mod+Shift+r exec sp-rename
} }
# Switch to workspace keybinds are managed by sp-profiles # Switch to workspace keybinds are managed by sdu
# bindsym $mod+n workspace number n # bindsym $mod+n workspace number n
# Move to workspace keybinds are managed by sp-profiles # Move to workspace keybinds are managed by sdu
# bindsym $mod+Shift+n move container to workspace number n # bindsym $mod+Shift+n move container to workspace number n
# Profile Workspace Setup # Profile Workspace Setup

View file

@ -2,9 +2,8 @@
op=$(echo -e "Output\nWindow\nRegion" | wofi -i --dmenu --width 250 --height 260 -k /dev/null | awk '{print tolower($1)}') op=$(echo -e "Output\nWindow\nRegion" | wofi -i --dmenu --width 250 --height 260 -k /dev/null | awk '{print tolower($1)}')
sc_dir="${HOME}/Pictures/Screen Capture/" sc_dir="${HOME}/Pictures/Screen Capture"
sleep 0.25 sleep 0.25
mkdir -p "${sc_dir}" mkdir -p "${sc_dir}"
sway-screenshot -m $op --output-folder "${HOME}/Pictures/Screen Capture/" sway-screenshot -m $op --output-folder "${sc_dir}"
#"'${sc_dir}'"

View file

@ -0,0 +1,165 @@
#!/usr/bin/env bash
set -e
AVAILABLE_MODES=(output window region)
function Help() {
cat <<EOF
Usage: sway-screenshot [options ..] -m [mode] -- [command]
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.
Options:
-h, --help show help message
-m, --mode one of: output, window, region
-o, --output-folder directory in which to save screenshot
-f, --filename the file name of the resulting screenshot
-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. sway-screenshot -m window -- mirage
Modes:
output take screenshot of an entire monitor
window take screenshot of an open window
region take screenshot of selected region
EOF
}
function Print() {
if [ $DEBUG -eq 0 ]; then
return 0
fi
1>&2 printf "$@"
}
function send_notification() {
if [ $SILENT -eq 1 ]; then
return 0
fi
notify-send "Screenshot saved" \
"Image saved in <i>${1}</i> and copied to the clipboard." \
-i "${1}"
}
function save_geometry() {
Print "Geometry: %s\n" "${1}"
if [ $CLIPBOARD -eq 0 ]; then
mkdir -p "$SAVEDIR"
grim -g "${1}" "$SAVE_FULLPATH"
local output="$SAVE_FULLPATH"
# Trim transparent pixels, in case the window was floating and partially
# outside the monitor
convert "${output}" -trim +repage "${output}"
wl-copy <"${output}"
send_notification "${output}"
[ -z "$COMMAND" ] || {
"$COMMAND" "${output}"
}
else
wl-copy < <(grim -g "${1}" - | convert - -trim +repage -)
fi
}
function begin_grab() {
local option=$1
case $option in
output)
local geometry=$(grab_output)
;;
region)
local geometry=$(grab_region)
;;
window)
local geometry=$(grab_window)
;;
esac
save_geometry "${geometry}"
}
function grab_output() {
slurp -or
}
function grab_region() {
slurp -d
}
function grab_window() {
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 '.[] | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height) \(.name)"')"
Print "Boxes:\n%s\n" "$boxes"
slurp -r <<<"$boxes"
}
function args() {
local options=$(getopt -o hf:o:m:ds --long help,filename:,output-folder:,mode:,clipboard-only,debug,silent -- "$@")
eval set -- "$options"
while true; do
case "$1" in
-h | --help)
Help
exit
;;
-o | --output-folder)
shift
SAVEDIR=$1
;;
-f | --filename)
shift
FILENAME=$1
;;
-m | --mode)
shift
echo "${AVAILABLE_MODES[@]}" | grep -wq $1
OPTION=$1
;;
--clipboard-only)
CLIPBOARD=1
;;
-d | --debug)
DEBUG=1
;;
-s | --silent)
SILENT=1
;;
--)
shift # Skip -- argument
COMMAND=${@:2}
break
;;
esac
shift
done
if [ -z $OPTION ]; then
Print "A mode is required\n\nAvailable modes are:\n\toutput\n\tregion\n\twindow\n"
exit 2
fi
}
if [ -z $1 ]; then
Help
exit
fi
CLIPBOARD=0
DEBUG=0
SILENT=0
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 "$@"
SAVE_FULLPATH="$SAVEDIR/$FILENAME"
[ $CLIPBOARD -eq 0 ] && Print "Saving in: %s\n" "$SAVE_FULLPATH"
begin_grab $OPTION

View file

@ -61,3 +61,4 @@
.local/share/dbus-1/services .local/share/dbus-1/services
.config/sway-de-utils .config/sway-de-utils
.var/app/io.github.softfever.OrcaSlicer/config/OrcaSlicer/user/default .var/app/io.github.softfever.OrcaSlicer/config/OrcaSlicer/user/default
.local/bin/sway-screenshot