How to remap a preconfigured keyboard shortcut under linux mint XFCE from a bourne shell script?












0















TLDR: I am trying to configure a keyboard shortcut from a script (on linux mint XFCE), but the preconfigured key binding gets in the way.



I have an installation script that installs apt packages, installs custom scripts, configures the OS, clones git repo's and installs hobby projects.



One of the things I want the script to do is to configure keyboard shortcuts for window snapping.
The idea is that if you press ctrl + shift + numpad[1-9] the window snaps to the associated location on the screen.



So ctrl + shift + 8 snaps the window to the top half of the screen

and ctrl + shift + 3 snaps to bottom lower corner.

I have the code roughly working:



XFCE_SHORTCUTS_FILE=~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
XFCE_SHORTCUTS_BACKUP="$XFCE_SHORTCUTS_FILE.bak"
xfce_set() {
key="/xfwm4/custom/$1"
action="$2"
xfconf-query --create -c xfce4-keyboard-shortcuts -t string -p "$key" -s "$action"
}
if [ ! -f "$XFCE_SHORTCUTS_BACKUP" -a -f $XFCE_SHORTCUTS_FILE ]
then
cp -n "$XFCE_SHORTCUTS_FILE" "$XFCE_SHORTCUTS_BACKUP"
xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"
xfce_set '<Primary><Shift>KP_Home' "tile_up_left_key"
xfce_set '<Primary><Shift>KP_Page_Up' "tile_up_right_key"
xfce_set '<Primary><Shift>KP_End' "tile_down_left_key"
xfce_set '<Primary><Shift>KP_Page_Down' "tile_down_right_key"
xfce_set '<Primary><Shift>KP_Left' "tile_left_key"
xfce_set '<Primary><Shift>KP_Right' "tile_right_key"
xfce_set '<Primary><Shift>KP_Up' "tile_up_key"
xfce_set '<Primary><Shift>KP_Down' "tile_down_key"
fi


Window snapping works for all of the corners and all of the sides.
By default linux mint binds maximize & restore window to alt + F10.
This is a weird combination with the corners and sides on numpad, so I want to map ctrl + shift + 5 instead.
I have already made an attempt to remap the key, but the old binding gets in the way.
I tried deleting the old binding first with xconf-query, but my attempt did not work:



xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"


Just to be clear, I strongly prefer a solution that does not require me to reboot my system.










share|improve this question





























    0















    TLDR: I am trying to configure a keyboard shortcut from a script (on linux mint XFCE), but the preconfigured key binding gets in the way.



    I have an installation script that installs apt packages, installs custom scripts, configures the OS, clones git repo's and installs hobby projects.



    One of the things I want the script to do is to configure keyboard shortcuts for window snapping.
    The idea is that if you press ctrl + shift + numpad[1-9] the window snaps to the associated location on the screen.



    So ctrl + shift + 8 snaps the window to the top half of the screen

    and ctrl + shift + 3 snaps to bottom lower corner.

    I have the code roughly working:



    XFCE_SHORTCUTS_FILE=~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
    XFCE_SHORTCUTS_BACKUP="$XFCE_SHORTCUTS_FILE.bak"
    xfce_set() {
    key="/xfwm4/custom/$1"
    action="$2"
    xfconf-query --create -c xfce4-keyboard-shortcuts -t string -p "$key" -s "$action"
    }
    if [ ! -f "$XFCE_SHORTCUTS_BACKUP" -a -f $XFCE_SHORTCUTS_FILE ]
    then
    cp -n "$XFCE_SHORTCUTS_FILE" "$XFCE_SHORTCUTS_BACKUP"
    xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
    xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"
    xfce_set '<Primary><Shift>KP_Home' "tile_up_left_key"
    xfce_set '<Primary><Shift>KP_Page_Up' "tile_up_right_key"
    xfce_set '<Primary><Shift>KP_End' "tile_down_left_key"
    xfce_set '<Primary><Shift>KP_Page_Down' "tile_down_right_key"
    xfce_set '<Primary><Shift>KP_Left' "tile_left_key"
    xfce_set '<Primary><Shift>KP_Right' "tile_right_key"
    xfce_set '<Primary><Shift>KP_Up' "tile_up_key"
    xfce_set '<Primary><Shift>KP_Down' "tile_down_key"
    fi


    Window snapping works for all of the corners and all of the sides.
    By default linux mint binds maximize & restore window to alt + F10.
    This is a weird combination with the corners and sides on numpad, so I want to map ctrl + shift + 5 instead.
    I have already made an attempt to remap the key, but the old binding gets in the way.
    I tried deleting the old binding first with xconf-query, but my attempt did not work:



    xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
    xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"


    Just to be clear, I strongly prefer a solution that does not require me to reboot my system.










    share|improve this question



























      0












      0








      0








      TLDR: I am trying to configure a keyboard shortcut from a script (on linux mint XFCE), but the preconfigured key binding gets in the way.



      I have an installation script that installs apt packages, installs custom scripts, configures the OS, clones git repo's and installs hobby projects.



      One of the things I want the script to do is to configure keyboard shortcuts for window snapping.
      The idea is that if you press ctrl + shift + numpad[1-9] the window snaps to the associated location on the screen.



      So ctrl + shift + 8 snaps the window to the top half of the screen

      and ctrl + shift + 3 snaps to bottom lower corner.

      I have the code roughly working:



      XFCE_SHORTCUTS_FILE=~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
      XFCE_SHORTCUTS_BACKUP="$XFCE_SHORTCUTS_FILE.bak"
      xfce_set() {
      key="/xfwm4/custom/$1"
      action="$2"
      xfconf-query --create -c xfce4-keyboard-shortcuts -t string -p "$key" -s "$action"
      }
      if [ ! -f "$XFCE_SHORTCUTS_BACKUP" -a -f $XFCE_SHORTCUTS_FILE ]
      then
      cp -n "$XFCE_SHORTCUTS_FILE" "$XFCE_SHORTCUTS_BACKUP"
      xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
      xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"
      xfce_set '<Primary><Shift>KP_Home' "tile_up_left_key"
      xfce_set '<Primary><Shift>KP_Page_Up' "tile_up_right_key"
      xfce_set '<Primary><Shift>KP_End' "tile_down_left_key"
      xfce_set '<Primary><Shift>KP_Page_Down' "tile_down_right_key"
      xfce_set '<Primary><Shift>KP_Left' "tile_left_key"
      xfce_set '<Primary><Shift>KP_Right' "tile_right_key"
      xfce_set '<Primary><Shift>KP_Up' "tile_up_key"
      xfce_set '<Primary><Shift>KP_Down' "tile_down_key"
      fi


      Window snapping works for all of the corners and all of the sides.
      By default linux mint binds maximize & restore window to alt + F10.
      This is a weird combination with the corners and sides on numpad, so I want to map ctrl + shift + 5 instead.
      I have already made an attempt to remap the key, but the old binding gets in the way.
      I tried deleting the old binding first with xconf-query, but my attempt did not work:



      xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
      xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"


      Just to be clear, I strongly prefer a solution that does not require me to reboot my system.










      share|improve this question
















      TLDR: I am trying to configure a keyboard shortcut from a script (on linux mint XFCE), but the preconfigured key binding gets in the way.



      I have an installation script that installs apt packages, installs custom scripts, configures the OS, clones git repo's and installs hobby projects.



      One of the things I want the script to do is to configure keyboard shortcuts for window snapping.
      The idea is that if you press ctrl + shift + numpad[1-9] the window snaps to the associated location on the screen.



      So ctrl + shift + 8 snaps the window to the top half of the screen

      and ctrl + shift + 3 snaps to bottom lower corner.

      I have the code roughly working:



      XFCE_SHORTCUTS_FILE=~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
      XFCE_SHORTCUTS_BACKUP="$XFCE_SHORTCUTS_FILE.bak"
      xfce_set() {
      key="/xfwm4/custom/$1"
      action="$2"
      xfconf-query --create -c xfce4-keyboard-shortcuts -t string -p "$key" -s "$action"
      }
      if [ ! -f "$XFCE_SHORTCUTS_BACKUP" -a -f $XFCE_SHORTCUTS_FILE ]
      then
      cp -n "$XFCE_SHORTCUTS_FILE" "$XFCE_SHORTCUTS_BACKUP"
      xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
      xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"
      xfce_set '<Primary><Shift>KP_Home' "tile_up_left_key"
      xfce_set '<Primary><Shift>KP_Page_Up' "tile_up_right_key"
      xfce_set '<Primary><Shift>KP_End' "tile_down_left_key"
      xfce_set '<Primary><Shift>KP_Page_Down' "tile_down_right_key"
      xfce_set '<Primary><Shift>KP_Left' "tile_left_key"
      xfce_set '<Primary><Shift>KP_Right' "tile_right_key"
      xfce_set '<Primary><Shift>KP_Up' "tile_up_key"
      xfce_set '<Primary><Shift>KP_Down' "tile_down_key"
      fi


      Window snapping works for all of the corners and all of the sides.
      By default linux mint binds maximize & restore window to alt + F10.
      This is a weird combination with the corners and sides on numpad, so I want to map ctrl + shift + 5 instead.
      I have already made an attempt to remap the key, but the old binding gets in the way.
      I tried deleting the old binding first with xconf-query, but my attempt did not work:



      xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>F10" -r -R
      xfce_set '<Primary><Shift>KP_Begin' "maximize_window_key"


      Just to be clear, I strongly prefer a solution that does not require me to reboot my system.







      linux keyboard-shortcuts linux-mint xfce sh






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 29 '18 at 7:40









      Mureinik

      2,47561625




      2,47561625










      asked Dec 29 '18 at 2:36









      Erik LievaartErik Lievaart

      11




      11






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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',
          autoActivateHeartbeat: false,
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388637%2fhow-to-remap-a-preconfigured-keyboard-shortcut-under-linux-mint-xfce-from-a-bour%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • 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%2fsuperuser.com%2fquestions%2f1388637%2fhow-to-remap-a-preconfigured-keyboard-shortcut-under-linux-mint-xfce-from-a-bour%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

          Plaza Victoria

          In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

          How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...