Skip to content

Commit

Permalink
xtool(): print tool specific explanations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Jun 30, 2022
1 parent 0742419 commit 48c1cfc
Showing 1 changed file with 54 additions and 52 deletions.
106 changes: 54 additions & 52 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Run 'x11docker --help' or scroll down to read usage information.
# More documentation at: https://github.com/mviereck/x11docker

Version="7.3.1-beta-4"
Version="7.3.1-beta-5"

# --enforce-i: Enforce running in interactive mode to allow commands tty and weston-launch in special setups.
grep -q -- "--enforce-i" <<< "$*" && case $- in
Expand Down Expand Up @@ -1868,10 +1868,7 @@ s0_active_plugins = core;composite;opengl;decor;resize;move;

case "$Windowmanagermode" in
host)
command -v "wmctrl" >/dev/null || note "Option --wm: Command 'wmctrl' not found.
It is recommended to install wmctrl to set only one virtual desktop
on window manager ${Windowmanagercommand}.
$Wikipackagesimage"
xtool --check "wmctrl"
;;
esac

Expand Down Expand Up @@ -2530,9 +2527,6 @@ check_screensize() { # check physical and virtual screen size (also o
Maxyaxis="$(grep ' connected' <<< "$Xrandroutput" | head -n1 | cut -dx -f2 | cut -d' ' -f1 | cut -d+ -f1)"
}
}
[ -z "$Maxxaxis" ] && note "check_screensize(): Could not determine your screen size.
Please improve this by installing 'xrandr' or use option --size=XxY.
$Wikipackages"
}

[ -n "$Screensize" ] && {
Expand Down Expand Up @@ -2583,19 +2577,17 @@ check_screensize() { # check physical and virtual screen size (also o
*) Screensize="${Xaxis}x${Yaxis}" ;;
esac

xtool --check --quiet cvt && {
xtool --check cvt && {
Modeline="$(xtool "cvt '$Xaxis' '$Yaxis'" | tail -n1 | cut -d' ' -f2-)"
Modeline="$(echo $Modeline | cut -d_ -f1)\" $(echo $Modeline | cut -d_ -f2- | cut -d' ' -f2-)"
} || {
debugnote "check_screensize(): command cvt not found."
}
verbose "Virtual screen size: $Screensize"
verbose "Physical screen size:
$(grep Screen <<< "$Xrandroutput" ||:)"

# create set of Modelines if needed
case "$Xserver" in
--xpra|--xpra2|--xvfb) xtool --check --quiet cvt && Modelinefile="$(create_modelinefile "${Maxxaxis}x${Maxyaxis}")" ;;
--xpra|--xpra2|--xvfb) xtool --check cvt && Modelinefile="$(create_modelinefile "${Maxxaxis}x${Maxyaxis}")" ;;
esac

return 0
Expand Down Expand Up @@ -4684,15 +4676,16 @@ create_xinitrc() { # create xinitrc: set up X environment, create c
*)
echo "# Keyboard layout"
[ -n "$Hostdisplay" ] && {
command -v setxkbmap >/dev/null && {
xtool --check setxkbmap && {
case "$Xkblayout" in
"") setxkbmap -display "$Hostdisplay" -print >> "$Xkbkeymapfile" ;;
*) setxkbmap "$Xkblayout" -print >> "$Xkbkeymapfile" ;;
"")
#setxkbmap -display "$Hostdisplay" -print >> "$Xkbkeymapfile"
echo "env DISPLAY=$Hostdisplay XAUTHORITY=$Hostxauthority setxkbmap -display $Hostdisplay -print >> $Xkbkeymapfile"
;;
*)
echo "setxkbmap '$Xkblayout' -print >> $Xkbkeymapfile"
;;
esac
:
} || {
note "setxkbmap not found. Need setxkbmap and xkbcomp to set keyboard layout.
$Wikipackagesimage"
}
[ -s "$Xkbkeymapfile" ] && {
echo "# set keyboard layout on $Newdisplay"
Expand Down Expand Up @@ -4878,13 +4871,7 @@ create_xinitrc() { # create xinitrc: set up X environment, create c
}
disable_xhost() { # remove any access to X server granted by xhost
local Line=
command -v xhost >/dev/null || {
warning "Command 'xhost' not found.
Can not check for possibly allowed network access to X.
Please install 'xhost'.
$Wikipackages"
return 1
}
xtool --check xhost || return 1
xtool "xhost 2>&1 | tail -n +2 /dev/stdin" | while read -r Line ; do # read all but the first line (header)
debugnote "xhost: Removing entry $Line"
xtool "xhost -'$Line'" # disable every entry
Expand Down Expand Up @@ -4939,7 +4926,7 @@ XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
return 0
}
xtool() { # run X tool command in X container if available, otherwise on host
local Tool Usexcontainer Check= Message
local Tool Toolinfo Usexcontainer Check= Message

Message="note"
case "${1:-}" in
Expand All @@ -4960,6 +4947,32 @@ xtool() { # run X tool command in X container if available,
esac

Tool="$(echo "${1:-}" | cut -d' ' -f1)"

case "$Tool" in
cvt) Toolinfo="x11docker uses cvt to create a set of screen resolutions
that can be seen and set by tools like xrandr." ;;
setxkbmap|xkbcomp) Toolinfo="x11docker uses setxkbmap and xkbcomp to set the keyboard
in new X server to same as on host or specified with --keymap." ;;
vainfo) Toolinfo="vainfo helps to configure VAAPI video decoding support." ;;
wmctrl) Toolinfo="x11docker uses wmctrl to configure window managers
to provide one virtual desktop only." ;;
xauth) Toolinfo="xauth creates and adjusts X authentication cookies." ;;
xbindkeys) Toolinfo="xbindkeys intercepts SUPER+v or ALT+v for option --clipboard." ;;
xclip) Toolinfo="xclip is needed for option --clipboard." ;;
xdpyinfo) Toolinfo="xdpyinfo provides some information about the host X server.
It tells x11docker about dpi and installed extensions like MIT-SHM." ;;
xdotool) Toolinfo="x11docker uses xdotool to hide the weston window
that is used in background for --xpra-xwayland." ;;
xfishtank) Toolinfo="xfishtank shows a fishtank with --xfishtank." ;;
xhost) Toolinfo="xhost controls network access to X. x11docker uses it to disable
undesired network access, or to allow some with option --xhost=ARG." ;;
xinit) Toolinfo="xinit serves to properly start and stop most X servers." ;;
xrandr) Toolinfo="xrandr allows to check or set the screen size (option --size).
with --xorg it also helps at options --rotate and --scale." ;;
xwininfo) Toolinfo="x11docker needs xwininfo for option --checkwindow
to get a list of currently open windows." ;;
esac

case "$Xcontainer" in
yes)
Usexcontainer="yes"
Expand All @@ -4978,8 +4991,8 @@ xtool() { # run X tool command in X container if available,
case "$Usexcontainer" in
no)
command -v "$Tool" >/dev/null || {
$Message "xtool(): Command '$Tool' not found on host.
Please install $Tool.
$Message "xtool(): Command '$Tool' not found on host. Please install $Tool.
$Toolinfo
$Wikipackagesimage"
return 1
}
Expand Down Expand Up @@ -9391,8 +9404,7 @@ check_options_interferences() { # check multiple option interferences, change se
no|"")
warning "Command 'xauth' not found.
Securing X access with cookie authentication is not possible.
Fallback: Disabling X authentication protocol. (option --no-auth)
$Wikipackagesimage"
Fallback: Disabling X authentication protocol (option --no-auth)."
check_fallback
;;
esac
Expand All @@ -9412,7 +9424,7 @@ check_options_interferences() { # check multiple option interferences, change se
# Check whether host X server has MIT-SHM enabled.
[ "$Winsubsystem" ] && Hostmitshm="no" || {
xtool "xdpyinfo 2>>$Xinitlogfile | grep -q 'MIT-SHM'" && Hostmitshm="yes" || Hostmitshm="no"
xtool --check xdpyinfo || Hostmitshm="yes" # if unknown, assume yes
xtool --check --quiet xdpyinfo || Hostmitshm="yes" # if unknown, assume yes
}

# --clipboard
Expand Down Expand Up @@ -9450,10 +9462,8 @@ check_options_interferences() { # check multiple option interferences, change se
;;
*)
xtool --check xclip || {
note "Option --clipboard with $Xserver needs xclip,
but xclip is not installed on your system.
Fallback: Disabling option --clipboard.
$Wikipackagesimage"
note "Option --clipboard with $Xserver needs xclip.
Fallback: Disabling option --clipboard."
check_fallback
Shareclipboard="no"
}
Expand All @@ -9464,8 +9474,7 @@ check_options_interferences() { # check multiple option interferences, change se
case "$Shareclipboard" in
superv|altv)
xtool --check xbindkeys || {
note "Option --clipboard=$Shareclipboard with $Xserver needs xbindkeys,
but xbindkeys is missing.
note "Option --clipboard=$Shareclipboard needs xbindkeys.
Fallback: Setting --clipboard=oneway."
check_fallback
Shareclipboard="oneway"
Expand All @@ -9489,11 +9498,8 @@ check_options_interferences() { # check multiple option interferences, change se
# xrandr: --scale --size --rotate
xtool --check xrandr || {
{ [ "$Scaling" ] || [ -n "$Rotation" ] || [ -n "$Screensize" ] ; } && {
note "Option --xorg needs 'xrandr' to support
options --size, --scale and --rotate.
Fallback: Disabling options --size, --scale and --rotate.
Please install 'xrandr'.
$Wikipackagesimage"
note "Option --xorg needs 'xrandr' for several options.
Fallback: Disabling options --size, --scale and --rotate."
check_fallback
Screensize=""
Rotation=""
Expand Down Expand Up @@ -9629,15 +9635,11 @@ check_options_interferences() { # check multiple option interferences, change se

# --checkwindow
[ -n "$Checkforopenwindow" ] && {
[ "$Xcontainer" = "no" ] && {
command -v xwininfo >/dev/null || {
note "Option --checkwindow needs 'xwininfo',
but xwininfo is not installed.
Fallback: Disabling option --checkwindow.
$Wikipackagesimage"
check_fallback
Checkforopenwindow=""
}
xtool --check xwininfo || {
note "Option --checkwindow needs 'xwininfo'.
Fallback: Disabling option --checkwindow."
check_fallback
Checkforopenwindow=""
}
}

Expand Down

0 comments on commit 48c1cfc

Please sign in to comment.