Using brightness/volume keys in tty/virtual console?

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











up vote
1
down vote

favorite












I'm wondering if it's possible to adjust (increment/decrement) brightness or volume with a laptop keyboard's dedicated brightness/volume keys in the virtual console.



Can the system be configured to perform a background operation in response to a single keypress, or is the only mode of interaction via the command line? (I have already found ways to make the adjustments via the command line.)



The only comparable example I can think of is the power button signaling an immediate system halt. However, I suspect that operates on a different level, since when I tried pressing it at the showkey prompt, it still shut down the system (rather than returning a keycode).




EDIT: Actually, while I've figured out how to do these things purely by the command line, I haven't figured out how to do them without root access. Any further insight on the matter would be greatly appreciated.







share|improve this question


























    up vote
    1
    down vote

    favorite












    I'm wondering if it's possible to adjust (increment/decrement) brightness or volume with a laptop keyboard's dedicated brightness/volume keys in the virtual console.



    Can the system be configured to perform a background operation in response to a single keypress, or is the only mode of interaction via the command line? (I have already found ways to make the adjustments via the command line.)



    The only comparable example I can think of is the power button signaling an immediate system halt. However, I suspect that operates on a different level, since when I tried pressing it at the showkey prompt, it still shut down the system (rather than returning a keycode).




    EDIT: Actually, while I've figured out how to do these things purely by the command line, I haven't figured out how to do them without root access. Any further insight on the matter would be greatly appreciated.







    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm wondering if it's possible to adjust (increment/decrement) brightness or volume with a laptop keyboard's dedicated brightness/volume keys in the virtual console.



      Can the system be configured to perform a background operation in response to a single keypress, or is the only mode of interaction via the command line? (I have already found ways to make the adjustments via the command line.)



      The only comparable example I can think of is the power button signaling an immediate system halt. However, I suspect that operates on a different level, since when I tried pressing it at the showkey prompt, it still shut down the system (rather than returning a keycode).




      EDIT: Actually, while I've figured out how to do these things purely by the command line, I haven't figured out how to do them without root access. Any further insight on the matter would be greatly appreciated.







      share|improve this question














      I'm wondering if it's possible to adjust (increment/decrement) brightness or volume with a laptop keyboard's dedicated brightness/volume keys in the virtual console.



      Can the system be configured to perform a background operation in response to a single keypress, or is the only mode of interaction via the command line? (I have already found ways to make the adjustments via the command line.)



      The only comparable example I can think of is the power button signaling an immediate system halt. However, I suspect that operates on a different level, since when I tried pressing it at the showkey prompt, it still shut down the system (rather than returning a keycode).




      EDIT: Actually, while I've figured out how to do these things purely by the command line, I haven't figured out how to do them without root access. Any further insight on the matter would be greatly appreciated.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 22 '17 at 14:52

























      asked Oct 14 '17 at 21:46









      Ryan Lue

      1997




      1997




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          It depends on which shell you use in your tty, but generally: Yes, you can. The readline library is the software component that makes these keyshortcuts possible.



          I only happen to know how it works with zsh, so I'll give an example with it. In case you use bash, try reading the "Readline Key Bindings" section in the manual - it looks like this is what you're looking for.



          With zsh:



          myfunc() 
          echo 'It works!'

          zle -N mywidget myfunc
          bindkey "^[OQ" mywidget


          The zle -N command is used to define something called a "zsh widget". Widgets can be used to call functions. The bindkey command let's you specify a keycode and a widget that will be executed whenever the key is pressed. The keycode ^[OQ happens to refer to the F2 key in my case. To find out what keycode your volume key has, press Ctrl+V and then hit the volume key (in my case, I would hit Fn+F2, which gives me ^[[26~).






          share|improve this answer
















          • 1




            This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
            – Ryan Lue
            Oct 14 '17 at 23:27










          • Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
            – Ryan Lue
            Oct 15 '17 at 4:33


















          up vote
          0
          down vote













          This is not a generalized solution to the problem, but after a couple days of troubleshooting, I discovered pommed, which is specifically for managing hotkeys on Apple laptops (which is what I have).



          In addition to allowing you to increment/decrement brightness/keyboard backlight/audio volume, it also automatically sets brightness when AC power is connected/disconnected (among other things). Way nicer than trying to write my own scripts for it.






          share|improve this answer




















            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%2f398163%2fusing-brightness-volume-keys-in-tty-virtual-console%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
            1
            down vote













            It depends on which shell you use in your tty, but generally: Yes, you can. The readline library is the software component that makes these keyshortcuts possible.



            I only happen to know how it works with zsh, so I'll give an example with it. In case you use bash, try reading the "Readline Key Bindings" section in the manual - it looks like this is what you're looking for.



            With zsh:



            myfunc() 
            echo 'It works!'

            zle -N mywidget myfunc
            bindkey "^[OQ" mywidget


            The zle -N command is used to define something called a "zsh widget". Widgets can be used to call functions. The bindkey command let's you specify a keycode and a widget that will be executed whenever the key is pressed. The keycode ^[OQ happens to refer to the F2 key in my case. To find out what keycode your volume key has, press Ctrl+V and then hit the volume key (in my case, I would hit Fn+F2, which gives me ^[[26~).






            share|improve this answer
















            • 1




              This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
              – Ryan Lue
              Oct 14 '17 at 23:27










            • Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
              – Ryan Lue
              Oct 15 '17 at 4:33















            up vote
            1
            down vote













            It depends on which shell you use in your tty, but generally: Yes, you can. The readline library is the software component that makes these keyshortcuts possible.



            I only happen to know how it works with zsh, so I'll give an example with it. In case you use bash, try reading the "Readline Key Bindings" section in the manual - it looks like this is what you're looking for.



            With zsh:



            myfunc() 
            echo 'It works!'

            zle -N mywidget myfunc
            bindkey "^[OQ" mywidget


            The zle -N command is used to define something called a "zsh widget". Widgets can be used to call functions. The bindkey command let's you specify a keycode and a widget that will be executed whenever the key is pressed. The keycode ^[OQ happens to refer to the F2 key in my case. To find out what keycode your volume key has, press Ctrl+V and then hit the volume key (in my case, I would hit Fn+F2, which gives me ^[[26~).






            share|improve this answer
















            • 1




              This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
              – Ryan Lue
              Oct 14 '17 at 23:27










            • Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
              – Ryan Lue
              Oct 15 '17 at 4:33













            up vote
            1
            down vote










            up vote
            1
            down vote









            It depends on which shell you use in your tty, but generally: Yes, you can. The readline library is the software component that makes these keyshortcuts possible.



            I only happen to know how it works with zsh, so I'll give an example with it. In case you use bash, try reading the "Readline Key Bindings" section in the manual - it looks like this is what you're looking for.



            With zsh:



            myfunc() 
            echo 'It works!'

            zle -N mywidget myfunc
            bindkey "^[OQ" mywidget


            The zle -N command is used to define something called a "zsh widget". Widgets can be used to call functions. The bindkey command let's you specify a keycode and a widget that will be executed whenever the key is pressed. The keycode ^[OQ happens to refer to the F2 key in my case. To find out what keycode your volume key has, press Ctrl+V and then hit the volume key (in my case, I would hit Fn+F2, which gives me ^[[26~).






            share|improve this answer












            It depends on which shell you use in your tty, but generally: Yes, you can. The readline library is the software component that makes these keyshortcuts possible.



            I only happen to know how it works with zsh, so I'll give an example with it. In case you use bash, try reading the "Readline Key Bindings" section in the manual - it looks like this is what you're looking for.



            With zsh:



            myfunc() 
            echo 'It works!'

            zle -N mywidget myfunc
            bindkey "^[OQ" mywidget


            The zle -N command is used to define something called a "zsh widget". Widgets can be used to call functions. The bindkey command let's you specify a keycode and a widget that will be executed whenever the key is pressed. The keycode ^[OQ happens to refer to the F2 key in my case. To find out what keycode your volume key has, press Ctrl+V and then hit the volume key (in my case, I would hit Fn+F2, which gives me ^[[26~).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 14 '17 at 22:44









            PawkyPenguin

            696110




            696110







            • 1




              This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
              – Ryan Lue
              Oct 14 '17 at 23:27










            • Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
              – Ryan Lue
              Oct 15 '17 at 4:33













            • 1




              This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
              – Ryan Lue
              Oct 14 '17 at 23:27










            • Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
              – Ryan Lue
              Oct 15 '17 at 4:33








            1




            1




            This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
            – Ryan Lue
            Oct 14 '17 at 23:27




            This is great! For anyone coming to this thread in the future, this is the closest link I could find: Bash Reference Manual: Readline Init File.
            – Ryan Lue
            Oct 14 '17 at 23:27












            Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
            – Ryan Lue
            Oct 15 '17 at 4:33





            Upon closer inspection, custom readline functions cannot be exposed to the shell directly, and can only be written into a program via Readline's API in C. In bash, it appears the best you can do is define a macro with bind -x, which still outputs to the terminal.
            – Ryan Lue
            Oct 15 '17 at 4:33













            up vote
            0
            down vote













            This is not a generalized solution to the problem, but after a couple days of troubleshooting, I discovered pommed, which is specifically for managing hotkeys on Apple laptops (which is what I have).



            In addition to allowing you to increment/decrement brightness/keyboard backlight/audio volume, it also automatically sets brightness when AC power is connected/disconnected (among other things). Way nicer than trying to write my own scripts for it.






            share|improve this answer
























              up vote
              0
              down vote













              This is not a generalized solution to the problem, but after a couple days of troubleshooting, I discovered pommed, which is specifically for managing hotkeys on Apple laptops (which is what I have).



              In addition to allowing you to increment/decrement brightness/keyboard backlight/audio volume, it also automatically sets brightness when AC power is connected/disconnected (among other things). Way nicer than trying to write my own scripts for it.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                This is not a generalized solution to the problem, but after a couple days of troubleshooting, I discovered pommed, which is specifically for managing hotkeys on Apple laptops (which is what I have).



                In addition to allowing you to increment/decrement brightness/keyboard backlight/audio volume, it also automatically sets brightness when AC power is connected/disconnected (among other things). Way nicer than trying to write my own scripts for it.






                share|improve this answer












                This is not a generalized solution to the problem, but after a couple days of troubleshooting, I discovered pommed, which is specifically for managing hotkeys on Apple laptops (which is what I have).



                In addition to allowing you to increment/decrement brightness/keyboard backlight/audio volume, it also automatically sets brightness when AC power is connected/disconnected (among other things). Way nicer than trying to write my own scripts for it.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 22 '17 at 16:00









                Ryan Lue

                1997




                1997



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398163%2fusing-brightness-volume-keys-in-tty-virtual-console%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?