What kind of code do keyboard “custom shortcuts” accept











up vote
1
down vote

favorite












The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator. This seems straight forward enough as a bash command: typing this into the terminal also produces a terminal window.



Currently I'm using Debian 9.5 (Stretch) and I'm trying to define some shortcuts for a new external keyboard. However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work. I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.










share|improve this question







New contributor




Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    1
    down vote

    favorite












    The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator. This seems straight forward enough as a bash command: typing this into the terminal also produces a terminal window.



    Currently I'm using Debian 9.5 (Stretch) and I'm trying to define some shortcuts for a new external keyboard. However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work. I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.










    share|improve this question







    New contributor




    Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator. This seems straight forward enough as a bash command: typing this into the terminal also produces a terminal window.



      Currently I'm using Debian 9.5 (Stretch) and I'm trying to define some shortcuts for a new external keyboard. However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work. I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.










      share|improve this question







      New contributor




      Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator. This seems straight forward enough as a bash command: typing this into the terminal also produces a terminal window.



      Currently I'm using Debian 9.5 (Stretch) and I'm trying to define some shortcuts for a new external keyboard. However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work. I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.







      bash keyboard shortcut-keys xorg






      share|improve this question







      New contributor




      Dmitry Vaintrob 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 question







      New contributor




      Dmitry Vaintrob 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 question




      share|improve this question






      New contributor




      Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Dec 10 at 1:29









      Dmitry Vaintrob

      1083




      1083




      New contributor




      Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Dmitry Vaintrob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted











          The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator




          There's two types of shortcuts. Some of them are managed by desktop environment - things like Ctrl + Alt + T. Different desktop environments manage different set of shortcuts. Such desktops as GNOME, Unity, LXDE, MATE, etc - they have code built-in for that and you can't really change those shortcuts without recompiling the desktop environment code. Desktops like Openbox, Blackbox - they don't manage these shortcuts. What you've been taught should be considered within context of your desktop environment. You should not need to declare shortcut for x-terminal-emulator for the desktops like GNOME and others I've mentioned earlier, because they already manage that.




          However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work.




          Custom shortcuts - what you declare yourself - operate on executables, that is you have to specify valid file existing on disk, such as /bin/bash or at least a command that exists in one of directories listed under $PATH variable. The desktop environment will run execve() syscall to start that app when you press the shortcut. This is also the reason why echo $? doesn't work - there is no shell to understand what $? means. The shell variables only have meaning inside shell. So what do you do? Tell the shortcut to start the shell ! Usually this is done via bash -c 'echo $?' for short commands or use a script with appropriate #! line at the top of the script. So key thing to remember shortcuts don't run shell commands, they run executables. To give a practical example where bash -c '...' is used, see How to create a shortcut that executes an xdotool command to simulate a key press?



          AS for why firefox didn't work for you, firefox may be checking for existing open windows or there is another error. Consider doing bash -c 'firefox > 2>&1 foxlogfile.txt' to find out the cause of the issue or any errors that may appear.




          I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.




          The short answer - there's no such documentation, really. So long as you remember that shortcuts use executable files instead of shell commands, that's all you really need. And of course you need to know what is the method of declaring shortcuts on your desktop - Openbox method is different from GNOME for example.



          P.S: Actually, there is a third type of shortcuts but they're not related to desktop environment, i.e. they are not GUI shortcuts. bash reads ~/.inputrc file, where you can declare certain commands to be executed for particular key combination. However, this is outside the scope of this question and is a different topic. See this for an example.



          P.S.2: Desktops based on GNOME, such as Unity, utilize GSettings and DConf database to apply particular settings to each user of desktop. As such, shortcuts under those environment can be controlled and set via command-line, but the same concept applies - they have to be either executables or something the desktop environment recognizes because it's in desktop environment's code. See this article about one of my scritps to disable Super key under Unity and Jacob Vlijm's answer for setting shortcuts via terminal ( remember this applies to GNOME-based ones only).



          See also




          • Do GUI based application execute shell commands in the background?






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Dmitry Vaintrob is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1099674%2fwhat-kind-of-code-do-keyboard-custom-shortcuts-accept%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted











            The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator




            There's two types of shortcuts. Some of them are managed by desktop environment - things like Ctrl + Alt + T. Different desktop environments manage different set of shortcuts. Such desktops as GNOME, Unity, LXDE, MATE, etc - they have code built-in for that and you can't really change those shortcuts without recompiling the desktop environment code. Desktops like Openbox, Blackbox - they don't manage these shortcuts. What you've been taught should be considered within context of your desktop environment. You should not need to declare shortcut for x-terminal-emulator for the desktops like GNOME and others I've mentioned earlier, because they already manage that.




            However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work.




            Custom shortcuts - what you declare yourself - operate on executables, that is you have to specify valid file existing on disk, such as /bin/bash or at least a command that exists in one of directories listed under $PATH variable. The desktop environment will run execve() syscall to start that app when you press the shortcut. This is also the reason why echo $? doesn't work - there is no shell to understand what $? means. The shell variables only have meaning inside shell. So what do you do? Tell the shortcut to start the shell ! Usually this is done via bash -c 'echo $?' for short commands or use a script with appropriate #! line at the top of the script. So key thing to remember shortcuts don't run shell commands, they run executables. To give a practical example where bash -c '...' is used, see How to create a shortcut that executes an xdotool command to simulate a key press?



            AS for why firefox didn't work for you, firefox may be checking for existing open windows or there is another error. Consider doing bash -c 'firefox > 2>&1 foxlogfile.txt' to find out the cause of the issue or any errors that may appear.




            I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.




            The short answer - there's no such documentation, really. So long as you remember that shortcuts use executable files instead of shell commands, that's all you really need. And of course you need to know what is the method of declaring shortcuts on your desktop - Openbox method is different from GNOME for example.



            P.S: Actually, there is a third type of shortcuts but they're not related to desktop environment, i.e. they are not GUI shortcuts. bash reads ~/.inputrc file, where you can declare certain commands to be executed for particular key combination. However, this is outside the scope of this question and is a different topic. See this for an example.



            P.S.2: Desktops based on GNOME, such as Unity, utilize GSettings and DConf database to apply particular settings to each user of desktop. As such, shortcuts under those environment can be controlled and set via command-line, but the same concept applies - they have to be either executables or something the desktop environment recognizes because it's in desktop environment's code. See this article about one of my scritps to disable Super key under Unity and Jacob Vlijm's answer for setting shortcuts via terminal ( remember this applies to GNOME-based ones only).



            See also




            • Do GUI based application execute shell commands in the background?






            share|improve this answer



























              up vote
              1
              down vote



              accepted











              The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator




              There's two types of shortcuts. Some of them are managed by desktop environment - things like Ctrl + Alt + T. Different desktop environments manage different set of shortcuts. Such desktops as GNOME, Unity, LXDE, MATE, etc - they have code built-in for that and you can't really change those shortcuts without recompiling the desktop environment code. Desktops like Openbox, Blackbox - they don't manage these shortcuts. What you've been taught should be considered within context of your desktop environment. You should not need to declare shortcut for x-terminal-emulator for the desktops like GNOME and others I've mentioned earlier, because they already manage that.




              However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work.




              Custom shortcuts - what you declare yourself - operate on executables, that is you have to specify valid file existing on disk, such as /bin/bash or at least a command that exists in one of directories listed under $PATH variable. The desktop environment will run execve() syscall to start that app when you press the shortcut. This is also the reason why echo $? doesn't work - there is no shell to understand what $? means. The shell variables only have meaning inside shell. So what do you do? Tell the shortcut to start the shell ! Usually this is done via bash -c 'echo $?' for short commands or use a script with appropriate #! line at the top of the script. So key thing to remember shortcuts don't run shell commands, they run executables. To give a practical example where bash -c '...' is used, see How to create a shortcut that executes an xdotool command to simulate a key press?



              AS for why firefox didn't work for you, firefox may be checking for existing open windows or there is another error. Consider doing bash -c 'firefox > 2>&1 foxlogfile.txt' to find out the cause of the issue or any errors that may appear.




              I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.




              The short answer - there's no such documentation, really. So long as you remember that shortcuts use executable files instead of shell commands, that's all you really need. And of course you need to know what is the method of declaring shortcuts on your desktop - Openbox method is different from GNOME for example.



              P.S: Actually, there is a third type of shortcuts but they're not related to desktop environment, i.e. they are not GUI shortcuts. bash reads ~/.inputrc file, where you can declare certain commands to be executed for particular key combination. However, this is outside the scope of this question and is a different topic. See this for an example.



              P.S.2: Desktops based on GNOME, such as Unity, utilize GSettings and DConf database to apply particular settings to each user of desktop. As such, shortcuts under those environment can be controlled and set via command-line, but the same concept applies - they have to be either executables or something the desktop environment recognizes because it's in desktop environment's code. See this article about one of my scritps to disable Super key under Unity and Jacob Vlijm's answer for setting shortcuts via terminal ( remember this applies to GNOME-based ones only).



              See also




              • Do GUI based application execute shell commands in the background?






              share|improve this answer

























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted







                The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator




                There's two types of shortcuts. Some of them are managed by desktop environment - things like Ctrl + Alt + T. Different desktop environments manage different set of shortcuts. Such desktops as GNOME, Unity, LXDE, MATE, etc - they have code built-in for that and you can't really change those shortcuts without recompiling the desktop environment code. Desktops like Openbox, Blackbox - they don't manage these shortcuts. What you've been taught should be considered within context of your desktop environment. You should not need to declare shortcut for x-terminal-emulator for the desktops like GNOME and others I've mentioned earlier, because they already manage that.




                However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work.




                Custom shortcuts - what you declare yourself - operate on executables, that is you have to specify valid file existing on disk, such as /bin/bash or at least a command that exists in one of directories listed under $PATH variable. The desktop environment will run execve() syscall to start that app when you press the shortcut. This is also the reason why echo $? doesn't work - there is no shell to understand what $? means. The shell variables only have meaning inside shell. So what do you do? Tell the shortcut to start the shell ! Usually this is done via bash -c 'echo $?' for short commands or use a script with appropriate #! line at the top of the script. So key thing to remember shortcuts don't run shell commands, they run executables. To give a practical example where bash -c '...' is used, see How to create a shortcut that executes an xdotool command to simulate a key press?



                AS for why firefox didn't work for you, firefox may be checking for existing open windows or there is another error. Consider doing bash -c 'firefox > 2>&1 foxlogfile.txt' to find out the cause of the issue or any errors that may appear.




                I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.




                The short answer - there's no such documentation, really. So long as you remember that shortcuts use executable files instead of shell commands, that's all you really need. And of course you need to know what is the method of declaring shortcuts on your desktop - Openbox method is different from GNOME for example.



                P.S: Actually, there is a third type of shortcuts but they're not related to desktop environment, i.e. they are not GUI shortcuts. bash reads ~/.inputrc file, where you can declare certain commands to be executed for particular key combination. However, this is outside the scope of this question and is a different topic. See this for an example.



                P.S.2: Desktops based on GNOME, such as Unity, utilize GSettings and DConf database to apply particular settings to each user of desktop. As such, shortcuts under those environment can be controlled and set via command-line, but the same concept applies - they have to be either executables or something the desktop environment recognizes because it's in desktop environment's code. See this article about one of my scritps to disable Super key under Unity and Jacob Vlijm's answer for setting shortcuts via terminal ( remember this applies to GNOME-based ones only).



                See also




                • Do GUI based application execute shell commands in the background?






                share|improve this answer















                The first thing I've been taught to do when I use Debian or Ubuntu is to create a shortcut (in my case Ctr-Alt-T) to open a terminal. To do this I create a new keyboard shortcut (in the X system's options>keyboard) with the code x-terminal-emulator




                There's two types of shortcuts. Some of them are managed by desktop environment - things like Ctrl + Alt + T. Different desktop environments manage different set of shortcuts. Such desktops as GNOME, Unity, LXDE, MATE, etc - they have code built-in for that and you can't really change those shortcuts without recompiling the desktop environment code. Desktops like Openbox, Blackbox - they don't manage these shortcuts. What you've been taught should be considered within context of your desktop environment. You should not need to declare shortcut for x-terminal-emulator for the desktops like GNOME and others I've mentioned earlier, because they already manage that.




                However, when I try to create shortcuts for other commands I can use from the terminal (such as firefox or echo "$"), the shortcut does not work.




                Custom shortcuts - what you declare yourself - operate on executables, that is you have to specify valid file existing on disk, such as /bin/bash or at least a command that exists in one of directories listed under $PATH variable. The desktop environment will run execve() syscall to start that app when you press the shortcut. This is also the reason why echo $? doesn't work - there is no shell to understand what $? means. The shell variables only have meaning inside shell. So what do you do? Tell the shortcut to start the shell ! Usually this is done via bash -c 'echo $?' for short commands or use a script with appropriate #! line at the top of the script. So key thing to remember shortcuts don't run shell commands, they run executables. To give a practical example where bash -c '...' is used, see How to create a shortcut that executes an xdotool command to simulate a key press?



                AS for why firefox didn't work for you, firefox may be checking for existing open windows or there is another error. Consider doing bash -c 'firefox > 2>&1 foxlogfile.txt' to find out the cause of the issue or any errors that may appear.




                I can't seem to find good documentation about what kind of command the create shortcut does take, but it does not quite seem to accept bash commands.




                The short answer - there's no such documentation, really. So long as you remember that shortcuts use executable files instead of shell commands, that's all you really need. And of course you need to know what is the method of declaring shortcuts on your desktop - Openbox method is different from GNOME for example.



                P.S: Actually, there is a third type of shortcuts but they're not related to desktop environment, i.e. they are not GUI shortcuts. bash reads ~/.inputrc file, where you can declare certain commands to be executed for particular key combination. However, this is outside the scope of this question and is a different topic. See this for an example.



                P.S.2: Desktops based on GNOME, such as Unity, utilize GSettings and DConf database to apply particular settings to each user of desktop. As such, shortcuts under those environment can be controlled and set via command-line, but the same concept applies - they have to be either executables or something the desktop environment recognizes because it's in desktop environment's code. See this article about one of my scritps to disable Super key under Unity and Jacob Vlijm's answer for setting shortcuts via terminal ( remember this applies to GNOME-based ones only).



                See also




                • Do GUI based application execute shell commands in the background?







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 10 at 4:00

























                answered Dec 10 at 1:46









                Sergiy Kolodyazhnyy

                68.9k9143303




                68.9k9143303






















                    Dmitry Vaintrob is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Dmitry Vaintrob is a new contributor. Be nice, and check out our Code of Conduct.













                    Dmitry Vaintrob is a new contributor. Be nice, and check out our Code of Conduct.












                    Dmitry Vaintrob is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1099674%2fwhat-kind-of-code-do-keyboard-custom-shortcuts-accept%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    數位音樂下載

                    When can things happen in Etherscan, such as the picture below?

                    格利澤436b