Last active
June 15, 2024 20:40
-
-
Save naelstrof/f9b74b5221cdc324c0911c89a47b8d97 to your computer and use it in GitHub Desktop.
Just screenshots the monitor that the mouse is on.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MONITORS=$(xrandr | grep -o '[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*') | |
# Get the location of the mouse | |
XMOUSE=$(xdotool getmouselocation | awk -F "[: ]" '{print $2}') | |
YMOUSE=$(xdotool getmouselocation | awk -F "[: ]" '{print $4}') | |
for mon in ${MONITORS}; do | |
# Parse the geometry of the monitor | |
MONW=$(echo ${mon} | awk -F "[x+]" '{print $1}') | |
MONH=$(echo ${mon} | awk -F "[x+]" '{print $2}') | |
MONX=$(echo ${mon} | awk -F "[x+]" '{print $3}') | |
MONY=$(echo ${mon} | awk -F "[x+]" '{print $4}') | |
# Use a simple collision check | |
if (( ${XMOUSE} >= ${MONX} )); then | |
if (( ${XMOUSE} <= ${MONX}+${MONW} )); then | |
if (( ${YMOUSE} >= ${MONY} )); then | |
if (( ${YMOUSE} <= ${MONY}+${MONH} )); then | |
# We have found our monitor! | |
maim -g "${MONW}x${MONH}+${MONX}+${MONY}" someplace.png | |
exit 0 | |
fi | |
fi | |
fi | |
fi | |
done | |
echo "Oh no the mouse is in the void!" | |
exit 1 |
Yeah! Go right ahead. Anything I post on gist I kinda intend to be under
the MIT license. But usually anything I post there is so tiny I forget to
do so haha. Thanks for letting me know.
…On Wed, Apr 29, 2020, 11:08 AM SabbathHex ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
@naelstrof <https://github.com/naelstrof> Hi! I wrote a fork
<https://gist.github.com/SabbathHex/87940496bd6bb9eec7f397bfe2ffe411> of
this gist with some additions: notifications and xclip integration for the
user to get the path of saved image. I am thinking about releasing it as
part of my wm-scripts <https://github.com/SabbathHex/wm-scripts> repo
which is licensed under GPL-3. Since this gist does not have an explicit
license - may I ask for your permission to release it under that license?
The attribution will be preserved, of course.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/f9b74b5221cdc324c0911c89a47b8d97#gistcomment-3275220>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIUIM7UKGR2SC4GWSKC3CDRPBNKXANCNFSM4MT46QMA>
.
Thanks!
-maim -g"${MONW}x${MONH}+${MONX}+${MONY}" someplace.png
+maim -g "${MONW}x${MONH}+${MONX}+${MONY}" someplace.png
Great script btw! Thank you
-maim -g"${MONW}x${MONH}+${MONX}+${MONY}" someplace.png +maim -g "${MONW}x${MONH}+${MONX}+${MONY}" someplace.pngGreat script btw! Thank you
Fixed. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@naelstrof Hi! I wrote a fork of this gist with some additions: notifications and xclip integration for the user to get the path of saved image. I am thinking about releasing it as part of my wm-scripts repo which is licensed under GPL-3. Since this gist does not have an explicit license - may I ask for your permission to release it under that license?
The attribution will be preserved, of course.