How to trick a program into thinking there is no X server running

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
12
down vote

favorite
1












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?










share|improve this question



























    up vote
    12
    down vote

    favorite
    1












    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?










    share|improve this question

























      up vote
      12
      down vote

      favorite
      1









      up vote
      12
      down vote

      favorite
      1






      1





      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?










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 16 mins ago









      progo

      874712




      874712










      asked 16 hours ago









      Luka Aleksić

      635




      635




















          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.






          share|improve this answer




















          • Thanks. It worked.
            – Luka Aleksić
            15 hours ago






          • 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






          • 1




            @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










          • @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


















          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].)






          share|improve this answer










          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.

















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            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






























            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.






            share|improve this answer




















            • Thanks. It worked.
              – Luka Aleksić
              15 hours ago






            • 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






            • 1




              @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










            • @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















            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.






            share|improve this answer




















            • Thanks. It worked.
              – Luka Aleksić
              15 hours ago






            • 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






            • 1




              @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










            • @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













            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.






            share|improve this answer












            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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 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




              @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










            • @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






            • 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






            • 1




              @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










            • @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













            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].)






            share|improve this answer










            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.





















              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].)






              share|improve this answer










              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.



















                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].)






                share|improve this answer










                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].)







                share|improve this answer










                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.









                share|improve this answer



                share|improve this answer








                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.



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery