Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SCRLINES=$(tput lines)
SCRCOLS=$(tput cols)
export SCRLINES SCRCOLS
awk 'BEGIN{
scrlines=ENVIRON["SCRLINES"]
scrcols=ENVIRON["SCRCOLS"]
}
{
# main awk code can use scrlines and scrcols variables
}'
awk 'BEGIN{"tput lines" | getline my; "tput cols" | getline mx; print "My screen is " mx " x " my}'
If you want to be sure, dump them :Mag0007 said:Nice, are the values of mx and my integers or string?
[blue]master #[/blue] awk --dump-variables 'BEGIN{"tput lines" | getline my; "tput cols" | getline mx}'
[blue]master #[/blue] grep "m[xy]" awkvars.out
mx: string ("167")
my: string ("55")
With the [tt]strtonum()[/tt] function. Suitable to convert hexadecimals and octals too. But better choose one of vlad's advices.Mag0007 said:if string, how can I convert them to integer?
#!/bin/sh
# Obtain current session values
#
declare -i width=$(xdpyinfo | grep -i dimension | awk '{ print $2 }' | awk 'BEGIN { FS = "x" } {print $1}')
declare -i heigt=$(xdpyinfo | grep -i dimension | awk '{ print $2 }' | awk 'BEGIN { FS = "x" } {print $2}')
# Compute new values (more from height, need the room for taksbars and so on)
#
(( width += -32 ))
(( heigt += -96 ))
#
if [ -z ${1} ]
then
echo "Geen parameter? Doe het dan maar met jezelf!"
gastheer=localhost
else
gastheer=${1}
fi
#
for s in {10,11,12,13,14,15,16,17,18,19}
do
if [ ! -e /tmp/.X${s}-lock ]
then
/usr/X11R6/bin/Xnest -name ${gastheer}:${s} -query ${gastheer} -once -geometry ${width}x${heigt} :${s}
exit 0
fi
done
What ?Truusvlugindewind said:As you can see, I added a negative number because I could not find how to "subtract" in a shell-script.
[blue]master #[/blue] i=15
[blue]master #[/blue] echo $i
15
[blue]master #[/blue] ((i-=1))
[blue]master #[/blue] echo $i
14
[blue]master #[/blue] let i-=2
[blue]master #[/blue] echo $i
12
[blue]master #[/blue] i=$((i-3))
[blue]master #[/blue] echo $i
9
[blue]master #[/blue] i=`expr $i - 4`
[blue]master #[/blue] echo $i
5
[blue]master #[/blue]i=`echo "$i-5" | bc`
[blue]master #[/blue] echo $i
0