add scripts section, add swayprop script

This commit is contained in:
Inhji 2022-12-18 20:38:23 +01:00
parent 63f836ec34
commit 0e0ab9d9a6
2 changed files with 61 additions and 17 deletions

40
config/scripts/swayprop.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/sh
# Copyright 2022 Subhaditya Nath
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
command -v jq >/dev/null || {
echo >&2 jq not found
echo >&2 Please install jq before using this utility
exit 1
}
TREE="$(swaymsg -t get_tree)"
COORDINATES="$(printf '%s\n' "$TREE" |
jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' |
slurp -B 000000 -f '%x,%y')"
EXITCODE=$?
[ $EXITCODE -eq 0 ] ||
exit $EXITCODE
X=${COORDINATES%,*}
Y=${COORDINATES#*,}
printf '%s\n' "$TREE" | jq ".. | select(.pid? and .visible?) | select(.rect.x == $X and .rect.y == $Y)"

View File

@ -1,28 +1,32 @@
- shell:
- [git submodule update --init --recursive, Updating submodules]
- create:
- ~/.ssh
- ~/.config/waybar
- ~/.config/sway
- ~/.config/rofi
- ~/.local/rofi/themes
- ~/.config/alacritty
- ~/.config/helix
- ~/.config/dunst
- link:
~/.ssh/config: config/ssh/config
~/.ssh/config:
create: true
path: config/ssh/config
~/.config/waybar:
create: true
glob: true
path: config/waybar/**
~/.config/rofi/config.rasi: config/rofi/config
~/.config/rofi/config.rasi:
create: true
path: config/rofi/config
~/.config/rofi:
glob: true
path: config/rofi/themes/**
~/.config/sway/config: config/sway/config
~/.config/starship.toml: config/starship/starship
~/.config/fish/config.fish: config/fish/config.fish
~/.config/alacritty/alacritty.yml: config/alacritty/alacritty.yml
~/.config/helix/config.toml: config/helix/config.toml
~/.config/sway/config:
create: true
path: config/sway/config
~/.config/fish/config.fish:
create: true
path: config/fish/config.fish
~/.config/alacritty/alacritty.yml:
create: true
path: config/alacritty/alacritty.yml
~/.config/helix/config.toml:
create: true
path: config/helix/config.toml
~/.config/dunst/dunstrc: config/dunst/dunstrc
~/.config/starship.toml: config/starship/starship
~/.local/bin/swayprop: config/scripts/swayprop.sh