New tool to offer a xprop equivalent for Sway

OBS-URL: https://build.opensuse.org/package/show/X11:Wayland/wlprop?expand=0&rev=1
This commit is contained in:
2024-08-14 11:41:55 +00:00
committed by Git OBS Bridge
commit 96ea416b7a
6 changed files with 133 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

3
_service Normal file
View File

@@ -0,0 +1,3 @@
<services>
<service name="download_files"/>
</services>

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env sh
# wlprop
#
# Licensed under the MIT license
# Copyright © 2022 bjosephmitchell@gmail.com
# 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.
#
# Dependencies:
# - swaymsg
# - jq
# - slurp
# - awk
# Get the sway tree and store the output
SWAY_TREE=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?)')
# Invoke slurp to let the user select a window
SELECTION=$(echo $SWAY_TREE | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)
# Extract the X, Y, Width, and Height from the selection
X=$(echo $SELECTION | awk -F'[, x]' '{print $1}')
Y=$(echo $SELECTION | awk -F'[, x]' '{print $2}')
W=$(echo $SELECTION | awk -F'[, x]' '{print $3}')
H=$(echo $SELECTION | awk -F'[, x]' '{print $4}')
# Find the window matching the selection
echo $SWAY_TREE | jq -r --argjson x $X --argjson y $Y --argjson w $W --argjson h $H \
'. | select(.rect.x == $x and .rect.y == $y and .rect.width == $w and .rect.height == $h)'

4
wlprop.changes Normal file
View File

@@ -0,0 +1,4 @@
-------------------------------------------------------------------
Wed Aug 14 10:52:19 UTC 2024 - Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
- Initial package

56
wlprop.spec Normal file
View File

@@ -0,0 +1,56 @@
#
# spec file for package wlprop
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2024 Georg Pfuetzenreuter <mail+rpm@georg-pfuetzenreuter.net>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: wlprop
Version: 0~git0.758c548
Release: 0
Summary: Script to query Wayland window properties
License: MIT
URL: https://gist.github.com/crispyricepc/f313386043395ff06570e02af2d9a8e0
Source: https://gist.githubusercontent.com/crispyricepc/f313386043395ff06570e02af2d9a8e0/raw/758c548bfb4be5b437c428c8062b3987f126f002/wlprop.sh
Requires: awk
Requires: jq
Requires: slurp
Requires: sway
%description
Shell script allowing to query window properties on Sway.
Wayland equivalent for "xprop".
%prep
sed '1s/env //' %{SOURCE0} > %{name}
%build
%install
install -Dm0755 %{name} %{buildroot}%{_bindir}/%{name}
%check
set -u
%if 0%{?suse_version} < 1600
result='a %{_bindir}/sh script, UTF-8 Unicode text executable'
%else
result='a %{_bindir}/sh script, Unicode text, UTF-8 text executable'
%endif
test "$(file -b %{buildroot}%{_bindir}/%{name})" = "$result"
%files
%{_bindir}/%{name}
%changelog