swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

commit 88c0993f868062a24568141b2c1c6f0fe74f2b1e
parent 641a0fc87fe3eeca51c7eda058fb3d9ee9582236
Author: awy <awy@awy.one>
Date:   Thu, 12 Jun 2025 17:42:14 +0300

xdotool port, current window screenshot functionality

Diffstat:
M.local/bin/cron/README.md | 7+++++--
M.local/bin/dmenuunicode | 4+++-
M.local/bin/maimpick | 24+++++++++++++++---------
3 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/.local/bin/cron/README.md b/.local/bin/cron/README.md @@ -5,7 +5,10 @@ These cronjobs have components that require information about your current displ When you add them as cronjobs, I recommend you precede the command with commands as those below: ``` -export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus; export DISPLAY=:0; . $HOME/.zprofile; then_command_goes_here +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $USER)/bus; export WAYLAND_DISPLAY=wayland-1; . $HOME/.zprofile; then_command_goes_here ``` -This ensures that notifications will display, xdotool commands will function and environmental variables will work as well. +This ensures that notifications will display, wtype/wlrctl commands will function and environmental variables will work as well. + +# Also important +DBUS_SESSION_BUS_ADDRESS variable will always have a random address in the /tmp directory when you are using dinit as your init system. diff --git a/.local/bin/dmenuunicode b/.local/bin/dmenuunicode @@ -11,7 +11,9 @@ chosen=$(cut -d ';' -f1 ~/.local/share/larbs/chars/* | wmenu -i -l 30 | sed "s/ # If you run this command with an argument, it will automatically insert the # character. Otherwise, show a message that the emoji has been copied. if [ -n "$1" ]; then - xdotool type "$chosen" + # currently only ascii supported in wlrctl + # wlrctl keyboard type"$chosen" + wtype "$chosen" else printf "%s" "$chosen" | wl-copy notify-send "'$chosen' copied to clipboard." & diff --git a/.local/bin/maimpick b/.local/bin/maimpick @@ -1,8 +1,8 @@ #!/bin/sh -# This is bound to Shift+PrintScreen by default, requires maim. It lets you +# This is bound to Shift+PrintScreen by default, requires grim. It lets you # choose the kind of screenshot to take, including copying the image or even -# highlighting an area to copy. scrotcucks on suicidewatch right now. +# highlighting an area to copy. # variables output="$(date '+%y%m%d-%H%M-%S').png" @@ -10,11 +10,17 @@ wclip_cmd="wl-copy -t image/png" ocr_cmd="wl-copy" case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\ncopy selected image to text" | bemenu -l 7 -i -p "Screenshot which area?")" in - "a selected area") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" pic-selected-"${output}" ;; - # "current window") maim -B -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;; - "full screen") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" pic-full-"${output}" ;; - "a selected area (copy)") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; - # "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;; - "full screen (copy)") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; - "copy selected image to text") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && slurp | grim -g - - > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; + "a selected area") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" pic-selected-"${output}" ;; + "current window") + geometry=$(swaymsg --raw -t get_tree | jq -r '.. | select(type == "object" and .focused == true) | .rect | "\(.x),\(.y) \(.width)x\(.height)"') + sleep 0.2 + grim -g "$geometry" pic-window-"${output}" ;; + "full screen") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" pic-full-"${output}" ;; + "a selected area (copy)") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; + "current window (copy)") + geometry=$(swaymsg --raw -t get_tree | jq -r '.. | select(type == "object" and .focused == true) | .rect | "\(.x),\(.y) \(.width)x\(.height)"') + sleep 0.2 + grim -g "$geometry" - | ${wclip_cmd} ;; + "full screen (copy)") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; + "copy selected image to text") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && slurp | grim -g - - > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; esac