How to trick a program into thinking there is no X server running
Clash Royale CLAN TAG#URR8PPP
up vote
12
down vote
favorite
I have this program that can run with both a text user interface and a graphical user interface.
It lacks any command line switch to force one or the other, rather I guess it somehow auto-detects whether we are in X or not (e.g. if I run it from a virtual terminal it enters its text mode, and if I run it from an X terminal emulator it opens a separate graphical window).
I'd like to force it into text mode and have it run inside the X terminal. How would I go about doing it?
x11
add a comment |Â
up vote
12
down vote
favorite
I have this program that can run with both a text user interface and a graphical user interface.
It lacks any command line switch to force one or the other, rather I guess it somehow auto-detects whether we are in X or not (e.g. if I run it from a virtual terminal it enters its text mode, and if I run it from an X terminal emulator it opens a separate graphical window).
I'd like to force it into text mode and have it run inside the X terminal. How would I go about doing it?
x11
add a comment |Â
up vote
12
down vote
favorite
up vote
12
down vote
favorite
I have this program that can run with both a text user interface and a graphical user interface.
It lacks any command line switch to force one or the other, rather I guess it somehow auto-detects whether we are in X or not (e.g. if I run it from a virtual terminal it enters its text mode, and if I run it from an X terminal emulator it opens a separate graphical window).
I'd like to force it into text mode and have it run inside the X terminal. How would I go about doing it?
x11
I have this program that can run with both a text user interface and a graphical user interface.
It lacks any command line switch to force one or the other, rather I guess it somehow auto-detects whether we are in X or not (e.g. if I run it from a virtual terminal it enters its text mode, and if I run it from an X terminal emulator it opens a separate graphical window).
I'd like to force it into text mode and have it run inside the X terminal. How would I go about doing it?
x11
x11
edited 16 mins ago
progo
874712
874712
asked 16 hours ago
Luka Aleksić
635
635
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
21
down vote
accepted
Usually just
unset DISPLAY
in command-line of the terminal. Some applications are smarter than that, and actually check permissions and type of the console versus pseudoterminal.
Thanks. It worked.
– Luka Aleksić
15 hours ago
2
Unfortunately, some really obstinate software will assumeDISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.
– Kevin
14 hours ago
1
@Kevin maybeDISPLAY=invalid:0
?
– sourcejedi
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,xterm
knows to fail near-instantly on NXDOMAIN.
– sourcejedi
10 hours ago
 |Â
show 1 more comment
up vote
8
down vote
If you want to disable X for a single command you can write
DISPLAY= ./my_command
Notice the strategical blank space after =
. More generally, you can set environment variables for a process by prefixing your command with a sequence of <variable>=<value>
separated by spaces. Since space serves as separator, =
immediately followed by a space clears the preceding variable. For instance:
A=a B=b C= D=d sh -c 'echo $A $B $C $D'
This will print
a b d
(I'm using sh -c
and single-quotes to prevent from substitution happening in the current shell, in other words, this ensures that we actually print the environment variables that the subprocess sees. Note that shell substitution happens before the individual arguments are passed to the subprocess, so there's only a single space between b
and d
in the output, just as if the command line were echo a b d
[with two spaces].)
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
21
down vote
accepted
Usually just
unset DISPLAY
in command-line of the terminal. Some applications are smarter than that, and actually check permissions and type of the console versus pseudoterminal.
Thanks. It worked.
– Luka Aleksić
15 hours ago
2
Unfortunately, some really obstinate software will assumeDISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.
– Kevin
14 hours ago
1
@Kevin maybeDISPLAY=invalid:0
?
– sourcejedi
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,xterm
knows to fail near-instantly on NXDOMAIN.
– sourcejedi
10 hours ago
 |Â
show 1 more comment
up vote
21
down vote
accepted
Usually just
unset DISPLAY
in command-line of the terminal. Some applications are smarter than that, and actually check permissions and type of the console versus pseudoterminal.
Thanks. It worked.
– Luka Aleksić
15 hours ago
2
Unfortunately, some really obstinate software will assumeDISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.
– Kevin
14 hours ago
1
@Kevin maybeDISPLAY=invalid:0
?
– sourcejedi
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,xterm
knows to fail near-instantly on NXDOMAIN.
– sourcejedi
10 hours ago
 |Â
show 1 more comment
up vote
21
down vote
accepted
up vote
21
down vote
accepted
Usually just
unset DISPLAY
in command-line of the terminal. Some applications are smarter than that, and actually check permissions and type of the console versus pseudoterminal.
Usually just
unset DISPLAY
in command-line of the terminal. Some applications are smarter than that, and actually check permissions and type of the console versus pseudoterminal.
answered 15 hours ago


Thomas Dickey
50.8k589161
50.8k589161
Thanks. It worked.
– Luka Aleksić
15 hours ago
2
Unfortunately, some really obstinate software will assumeDISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.
– Kevin
14 hours ago
1
@Kevin maybeDISPLAY=invalid:0
?
– sourcejedi
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,xterm
knows to fail near-instantly on NXDOMAIN.
– sourcejedi
10 hours ago
 |Â
show 1 more comment
Thanks. It worked.
– Luka Aleksić
15 hours ago
2
Unfortunately, some really obstinate software will assumeDISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.
– Kevin
14 hours ago
1
@Kevin maybeDISPLAY=invalid:0
?
– sourcejedi
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,xterm
knows to fail near-instantly on NXDOMAIN.
– sourcejedi
10 hours ago
Thanks. It worked.
– Luka Aleksić
15 hours ago
Thanks. It worked.
– Luka Aleksić
15 hours ago
2
2
Unfortunately, some really obstinate software will assume
DISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.– Kevin
14 hours ago
Unfortunately, some really obstinate software will assume
DISPLAY=:0
if it's unset. I believe you can fix that by running it under a different user and using iptables to drop loopback X11, but that's pretty gross.– Kevin
14 hours ago
1
1
@Kevin maybe
DISPLAY=invalid:0
?– sourcejedi
13 hours ago
@Kevin maybe
DISPLAY=invalid:0
?– sourcejedi
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
no... that would only try to make the program connect to the display on "invalid". It might not timeout rapidly enough to be useful.
– Thomas Dickey
13 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,
xterm
knows to fail near-instantly on NXDOMAIN.– sourcejedi
10 hours ago
@ThomasDickey fite me :-). There are two X libraries, and the old one was migrated to be a wrapper for the new low-level one. At least on my machine,
xterm
knows to fail near-instantly on NXDOMAIN.– sourcejedi
10 hours ago
 |Â
show 1 more comment
up vote
8
down vote
If you want to disable X for a single command you can write
DISPLAY= ./my_command
Notice the strategical blank space after =
. More generally, you can set environment variables for a process by prefixing your command with a sequence of <variable>=<value>
separated by spaces. Since space serves as separator, =
immediately followed by a space clears the preceding variable. For instance:
A=a B=b C= D=d sh -c 'echo $A $B $C $D'
This will print
a b d
(I'm using sh -c
and single-quotes to prevent from substitution happening in the current shell, in other words, this ensures that we actually print the environment variables that the subprocess sees. Note that shell substitution happens before the individual arguments are passed to the subprocess, so there's only a single space between b
and d
in the output, just as if the command line were echo a b d
[with two spaces].)
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
8
down vote
If you want to disable X for a single command you can write
DISPLAY= ./my_command
Notice the strategical blank space after =
. More generally, you can set environment variables for a process by prefixing your command with a sequence of <variable>=<value>
separated by spaces. Since space serves as separator, =
immediately followed by a space clears the preceding variable. For instance:
A=a B=b C= D=d sh -c 'echo $A $B $C $D'
This will print
a b d
(I'm using sh -c
and single-quotes to prevent from substitution happening in the current shell, in other words, this ensures that we actually print the environment variables that the subprocess sees. Note that shell substitution happens before the individual arguments are passed to the subprocess, so there's only a single space between b
and d
in the output, just as if the command line were echo a b d
[with two spaces].)
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
8
down vote
up vote
8
down vote
If you want to disable X for a single command you can write
DISPLAY= ./my_command
Notice the strategical blank space after =
. More generally, you can set environment variables for a process by prefixing your command with a sequence of <variable>=<value>
separated by spaces. Since space serves as separator, =
immediately followed by a space clears the preceding variable. For instance:
A=a B=b C= D=d sh -c 'echo $A $B $C $D'
This will print
a b d
(I'm using sh -c
and single-quotes to prevent from substitution happening in the current shell, in other words, this ensures that we actually print the environment variables that the subprocess sees. Note that shell substitution happens before the individual arguments are passed to the subprocess, so there's only a single space between b
and d
in the output, just as if the command line were echo a b d
[with two spaces].)
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
If you want to disable X for a single command you can write
DISPLAY= ./my_command
Notice the strategical blank space after =
. More generally, you can set environment variables for a process by prefixing your command with a sequence of <variable>=<value>
separated by spaces. Since space serves as separator, =
immediately followed by a space clears the preceding variable. For instance:
A=a B=b C= D=d sh -c 'echo $A $B $C $D'
This will print
a b d
(I'm using sh -c
and single-quotes to prevent from substitution happening in the current shell, in other words, this ensures that we actually print the environment variables that the subprocess sees. Note that shell substitution happens before the individual arguments are passed to the subprocess, so there's only a single space between b
and d
in the output, just as if the command line were echo a b d
[with two spaces].)
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 6 hours ago
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 8 hours ago
tobi_s
1812
1812
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
tobi_s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476883%2fhow-to-trick-a-program-into-thinking-there-is-no-x-server-running%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password