Skip to content

Instantly share code, notes, and snippets.

@celestefox
Created July 24, 2023 10:36
Show Gist options
  • Save celestefox/a2cd32e939cfa60c745de5cdfe3a3c8c to your computer and use it in GitHub Desktop.
Save celestefox/a2cd32e939cfa60c745de5cdfe3a3c8c to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p xdotool hacksaw
set -euo pipefail
IFS=$' '
shopt -s lastpipe
# hacksaw to get coords, this needs lastpipe
hacksaw -c "#5511bb" -f "%w %h %x %y" | read -r W H X Y
#echo "$X $Y $W $H"
# get a random number to use as an unique id
our_id="kh-$RANDOM"
# run kitty, it is assumed that class kittyhere will be made floating
systemd-cat kitty --class kittyhere --name "$our_id" -o remember_window_size=no -o initial_window_width="$W" -o initial_window_height="$H" &
# move the window, this happens after the window is already painted but it works at least
xdotool search --sync --classname "$our_id" windowmove "$X" "$Y"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment