-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinmess-dim
executable file
·77 lines (56 loc) · 1.57 KB
/
winmess-dim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# 2021-08-27 WinMess Inspired by WinGrid-antiX
# Get screen resolutions and compose the placement hint.
PROGNAME="${0##*/}"
PROGDIR="${0%/*}"
PROGVERSION=$($PROGDIR/winmess-version)
LIBDIR="$PROGDIR/../lib"
# Utility functions
# -----------------
# Location of utility functions.
LIBFILE="$LIBDIR/winmess-lib.sh"
. $LIBFILE
# Help and Information
# --------------------
init_help $1
# User Configurable Settings
# --------------------------
# Location of the user configurable settings file.
CONFIGFILE="$HOME/.config/winmess.conf"
# Obtain the user specifiable configuration.
if [ -f $CONFIGFILE ]
then
. $CONFIGFILE
else
# Display an error message and exit.
ERRMSG=" $CONFIGFILE \n Was not found \n\n Exiting..."
error "$ERRMSG"
exit 1
fi
# Initialize screen resolutions.
init_res
# Call xwininfo.
cat <<EOS
Screen Resolutions and the Placement Hint
For use in $HOME/.config/winmess.conf
Please, click on a window to see the hint to it's placement...
EOS
INFO=$(xwininfo)
AX=$(field 'Absolute upper-left X' "$INFO")
AY=$(field 'Absolute upper-left Y' "$INFO")
RX=$(field 'Relative upper-left X' "$INFO")
RY=$(field 'Relative upper-left Y' "$INFO")
X=$(($AX-$RX))
Y=$(($AY-$RY))
W=$(field Width "$INFO")
H=$(field Height "$INFO")
cat <<EOS
The placement hint: "x:$X y:$Y w:$W h:$H"
May be some mino inaccuracies in values (less than 10 pixels)...
Screen width: $SCREENWIDTH
Screen height: $SCREENHEIGHT
Screen half width: $SCREENHALFWIDTH
Screen half height: $SCREENHALFHEIGHT
Gravity: $GRAVITY
Always zero though...
EOS