Change behaviour of wireless toggle button

Forum Forums General Software Change behaviour of wireless toggle button

  • This topic has 16 replies, 5 voices, and was last updated May 25-3:21 pm by TheBigBadBoy.
Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #82984
    Member
    TheBigBadBoy

      Hello !

      I’m just wondering if it was possible to change the behaviour of the wireless toggle button (on my keyboard, it is a airplane logo).

      In my case, I want to retrieve the last state of “connection”. But now, every time I toggle off wireless mode the Bluetooth keeps turning ON (even if Bluetooth was not enabled before).

      I want the button to do the same as “Right click on Wi-Fi status from connman -> (un)tick ‘Offline mode'”.

      I also know it is possible since it is what the button does on Windows (dual boot).

      #83096
      Member
      TheBigBadBoy
        Helpful
        Up
        0
        ::

        No one has a solution? Even a clue?

        I know there is already some keys at ‘~/.icewm/keys’ but I don’t see the wireless toggle button…

        I wish someone could help me !

        #83102
        Member
        ModdIt
          Helpful
          Up
          1
          ::

          I wish someone could help me !. Have you tried to help yourself?.

          DDG or whatever is your friend.
          Had you tried you would have found that a keypress gives some code depending on device
          which is translated to a code.
          As you have also windoze you can startwith.
          https://docs.microsoft.com/en-us/windows/win32/learnwin32/keyboard-input

          You have the device and can find out how to read and convert a code to get the result you want.

          #83103
          Member
          TheBigBadBoy
            Helpful
            Up
            0
            ::

            Thank you for the reply !

            I’ll dig in ^^

            #83104
            Member
            ModdIt
              Helpful
              Up
              2
              ::

              Thanks for understanding reaction.
              Sadly there is no standard for keyboard codes within the computer industry,
              with older and common devices someone may already have a fix.

              In your case the device is not so common and probably not often used with
              debian antiX.

              When you ask for help it is better to repeat info rather than hoping a
              possible helper/user will trawl through previous posts to figure out what
              you are using and up against.

              #83105
              Member
              madibi
                Helpful
                Up
                1
                ::

                I’m not sure about how it is done your toggle button.
                You can try with the “xev”, and if you are lucky, when you press the toggle button, the xev command gives you back a code.
                Then with “xmodmap” you can change that code to the function that you desire.
                For example, in the Apple keyboard in that way I can change the right-apple in the AltGr of the pc keyboard
                I hope that this info may help you
                good luck!
                m

                #83106
                Member
                TheBigBadBoy
                  Helpful
                  Up
                  1
                  ::

                  > When you ask for help it is better to repeat info rather than hoping a
                  > possible helper/user will trawl through previous posts to figure out what
                  > you are using and up against.
                  Okay, I get it. Sorry for my ignorance…

                  Thanks to you both for your answers, I’ve already made good progress.
                  I didn’t know that it was possible to get the code of a keyboard key, so I looked into it (after trying ‘xev’). So I came up with a solution: ‘showkey’. My button is found to have the code 247, and in ‘xmodmap’ no key/output is assigned to it.
                  So I’d like to put in an appropriate output (hopefully overwriting the current behaviour), e.g. ‘XF86ToggleWireless’ (in the same idea as ‘XF86AudioLowerVolume’) but it doesn’t exist.
                  Once done, I would add to the commands in ‘~/.icewm/keys’ what this button will do.

                  So my problem is: what logical button/key (XF86xxxx?) could I give to the physical wireless disconnect button?
                  In the list here (https://wiki.linuxquestions.org/wiki/XF86_keyboard_symbols), could I take any unused key ? (Or perhaps there is a better key than XF86xxxx?)

                  P.S. English is not my first language, so please excuse me if I choose my words badly…

                  #83107
                  Member
                  madibi
                    Helpful
                    Up
                    1
                    ::

                    if you google search: “xmodmap keycode list”

                    you can find a lot of codes useful for you (e.g.: https://wiki.linuxquestions.org/wiki/List_of_Keysyms_Recognised_by_Xmodmap )

                    Then you have to write in the terminal something like:
                    xmodmap -e “keycode 134 = ISO_Level3_Shift” (<== This is the command for the Mac keyboard that I mentioned before)

                    in your case you have to change the value “134” with the code of the button that xev gives to you (you wrote =247),
                    and “ISO_Level3_Shift” with the function that you will find in your research of codes.

                    At the end you can also write an utility that you can add to the autostart.
                    For this latest point others are better prepared than me 🙂

                    I think that you are very close to your goal!

                    m

                    EDIT
                    I’ve also found: https://wiki.linuxquestions.org/wiki/XF86_keyboard_symbols

                    • This reply was modified 11 months, 3 weeks ago by madibi.
                    #83113
                    Member
                    ModdIt
                      Helpful
                      Up
                      1
                      ::

                      Just one more tip, make a snapshot of your antiX, prepare a non persistant live
                      stick from that, when experimenting or testing use the stick.
                      Once things work the way you want do a PERSONAL remaster so your settings and
                      customisation are kept.
                      Testing in above manner while running live means shutting down at any time will
                      lose any breaking or non working changes giving you a clean system on reboot.

                      When you are ready you can then transfer settings to your installed system or
                      reinstall from the stick. Y

                      #83118
                      Member
                      TheBigBadBoy
                        Helpful
                        Up
                        0
                        ::

                        Thanks, I’m almost done !

                        Here is the code that will execute the button :

                        
                        if [ "$(connmanctl services | sed -n 13p)" ]; then
                            sudo connmanctl enable offline
                        else
                            sudo connmanctl disable offline
                        fi
                        

                        Perhaps not the most elegant, but it works (I tested it IN A SHELL).

                        The problem I have now is that it appears that the button cannot be overwriten.
                        I did ‘xmodmap -e “keycode 247 = F13″‘ since F13 was not used, then added F13 to keys in ‘~/.icewm/keys’ : ‘key “F13” zzzfm’ (simple test to see if it works). But zzzfm won’t open, andthe behaviour of that button did not change unfortunately…
                        Is there any hope to overwrite its behaviour ? If it can help, keycode 247 (the toggle wireless button) is sent when I press the “Fn + F11” keys.

                        If there is no way to achieve this, well I will definitely use another combination of keys :’)

                        • This reply was modified 11 months, 3 weeks ago by TheBigBadBoy.
                        #83123
                        Member
                        madibi
                          Helpful
                          Up
                          0
                          ::

                          I don’t have your keyboard, I guess I should rather try the following:

                          ‘xmodmap -e “keycode 247 = XF86WLAN’ (for the wifi)

                          (for the bluetooth the command should be:
                          ‘xmodmap -e “keycode 247 = XF86Bluetooth’ )

                          please try it and let me know 🙂

                          m

                          • This reply was modified 11 months, 3 weeks ago by madibi.
                          #83128
                          Member
                          wildstar84
                            Helpful
                            Up
                            0
                            ::

                            I’ve had various struggles getting special keys to work and wrote a rather long (tl;dr) blogposts detailing my various solutions a few years ago. It’s a long read, but you may find some things of use in it not covered here.

                            https://wildstar84.wordpress.com/2016/04/27/make-special-hp-laptop-touchpad-toggle-key-work-in-linux/

                            Regards,

                            Jim

                            #83131
                            Member
                            blur13
                              Helpful
                              Up
                              0
                              ::

                              “If there is no way to achieve this, well I will definitely use another combination of keys :’)”

                              This will make your life easier. I’ve rerouted a lot of “special keys” to Super+”any key thats easy to reach from the home row” as a work-around, to discover that I actually prefer it that way. Adjusting e.g. brightness with Super+q/a is a lot quicker than stopping whatever you’re doing and looking for the right keys among the F-row.

                              #83151
                              Member
                              TheBigBadBoy
                                Helpful
                                Up
                                0
                                ::

                                Here is an update :

                                First, I will no longer use xmodmap, since it does nothing interesting in my case. In fact, thanks to wildstar84 I have discovered xbindkeys.
                                This program helped me in one thing : now, I know that the key binded to my wireless toggle button is XF86RFKill. I don’t need xbindkeys anymore either, since we can do exactly the same in ‘~/.icewm/keys’.

                                So, at the time I am writing, I can ALREADY toggle the wireless state (using a custom combination of keys) ! THANKS to every one in this thread ^^
                                I needed to create a script /usr/local/bin/wireless_toggle_button.sh.

                                I wanted to test further, by using the corresponding key with an airplane logo on it (with the key XF86RFKill). The fact is, if I add a command to that key (in icewm/keys or xbindkeys-config), it really add that command (and not overwrite it). For example, if I set ‘key “XF86RFKill” zzzfm’, then zzzfm will be opened at the same time rfkill will toggle each device states.
                                I don’t really want to “suffer” for “nothing”, trying for example the solution of wildstar84. It looks a bit too complicated for me.

                                EDIT:
                                Just one question : the script I’m using needs super-user privileges. So unfortunately it can only works (with the combination of keys) if I entered previously my password in a shell… How can I deal with it ?

                                • This reply was modified 11 months, 3 weeks ago by TheBigBadBoy.
                                #83620
                                Member
                                TheBigBadBoy
                                  Helpful
                                  Up
                                  0
                                  ::

                                  Tadam, I finally got something to work, without root password !

                                  So, for any future reference, here are all the things I have done :

                                  Edit ‘~/.icewm/keys’ and add ‘key “Super+F11” wireless_toggle_button.sh’.
                                  Create a script ‘/usr/local/bin/wireless_toggle_button.sh’. The code in it is

                                  
                                  #!/bin/bash
                                  
                                  if [ "$(connmanctl services | sed -n 13p)" ]; then
                                      sudo connmanctl enable offline
                                  else
                                      sudo connmanctl disable offline
                                  fi
                                  

                                  And finally, change sudoers file in order to execute connmanctl without password (perhaps it is not the best solution, but it works).
                                  So ‘sudo visudo’ and add ‘ALL ALL=NOPASSWD:/usr/local/bin/connmanctl’.

                                  And voilĂ  !

                                Viewing 15 posts - 1 through 15 (of 17 total)
                                • You must be logged in to reply to this topic.