Custom Keybindings Openbox
Total Page:16
File Type:pdf, Size:1020Kb
How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... Daniel Rosehill Blog Linux, writing, and more ALL GENERAL FREELANCING HOW TO LINUX BACKUP TECH MISC REVIEWS VIDEO ABOUT I’M HERE TOO LINKS MY WRITING 17 IYYAR 5780 How to Add Custom Keybindings in Openbox Topics: Customiza�on, Linux, Openbox, Ubuntu If you’re s�ll running LXDE, or are using Openbox through some other lightweight desktop environment (DE) then you might be interested in crea�ng custom keybindings to be able to do everything from shu�ng down the computer to opening your favorite Chrome app at the touch of a bu�on. Fortunately, because Openbox, like LXDE, is a lightweight piece of so�ware, crea�ng these is not too complicated. Follow these steps to have your keyboard doing exactly what you want — just be careful not to overwrite keyboard shortcuts built into programs which you might use regularly! Open the Openbox con�guration �le 1 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... Creating Openbox keybindings in LXDE (Linux Ubuntu) Firstly, navigate to the default Openbox configura�on file. In both LXDE and Ubuntu this can be found within: 1. /home/$user/.config/openbox (Replacing $user with your username). If you’re using LXDE the file is lxde-rc.xml. In Lubuntu, the corresponding file is lubuntu-rc.xml. It’s best prac�ce to take a backup of the file before making any chances. I typically just append the date as a suffix in DDMMYY format: 1. cp lxde-rc.xml lxde-rc-DDMMYY.xml You can then open the file in your IDE of choice. Use xev to capture key 2 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... identi�ers A�aching keys to specific commands is as easy as looking up the key’s iden�fier. You can use the xev tool in order to do this. Xev will output the coordinates of your mouse movements and the iden�fiers of the keys that you type back into the terminal. Just make sure to type the keystrokes while the capture box is in focus: Assign Keybindings A�er ge�ng familiar with the layout of lxde.rc.xml you can begin adding in your own custom keybindings — or reassigning exis�ng ones. Just pay a�en�on to the <context> tags as these will determine where 3 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... the keybindings are allowed to run. But you can easily decipher the basic format: 1. <keybind key=”Scroll_Lock”> 2. <action name=”Execute”> 3. <command>sudo pm-suspend</command> 4. </action> 5. </keybind> The above is a keybinding I have been using for years to make it easy for me to put my desktop into suspend rather than turning it off. It requires the pm-u�ls u�lity. But simply pressing the scroll lock key will automa�cally put my PC into the suspend state. The only other edit I had to create to make this work was to disable wake from USB devices. You can find the wake states of your various devices using: 1. cat /proc/acpi/wakeup A�er some experimenta�on I was then able to pass: 1. <br>sudo sh -c “echo XHC > /proc/acpi/wakeup” If you like the thought of se�ng a suspend keybinding but are running into difficulty with your wireless mouse/keyboard waking the device without your interven�on, you can find more informa�on and details on AskUbuntu and here. Sample edited default Openbox 4 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... con�guration �le Lower (10%), raise (10%), and toggle mute using the bo�om three bu�ons on the numeric keypad: 1. <keybind key=”KP_End”> 2. <action name=”Execute”> 3. <command>amixer -D pulse set Master 10%-</command> 4. </action> 5. </keybind> 6. <keybind key=”KP_Down”> 7. <action name=”Execute”> 8. <command>amixer -D pulse set Master 10%+</command> 9. </action> 10. </keybind> 11. <keybind key=”KP_Next”> 12. <action name=”Execute”> 13. <command>amixer -D pulse set Master 1+ toggle</command> 14. </action> 15. </keybind> I use the Pause Break key to call up a Chrome App shortcut that launches Brain.fm: 1. <keybind key=”Pause”> 2. <action name=”Execute”> 3. <command>/opt/google/chrome/google-chrome — profile- directory=Default — app-id=dgksfs9fsfsfksf</command> 4. </action> 5. </keybind> I use Flameshot for screenshots. I mapped the flameshot gui command onto the Print Screen key: 1. <keybind key=”Print”> 2. <action name=”Execute”> 3. <command>flameshot gui</command> 4. </action> 5. </keybind> And of course I can suspend the computer directly using Scroll Lock. Just make sure to install pm-utils first: 5 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... 1. <keybind key=”Scroll_Lock”> 2. <action name=”Execute”> 3. <command>sudo pm-suspend</command> 4. </action> 5. </keybind> Here’s the snippet in full: 1. <?xml version="1.0" encoding="UTF-8"?> 2. 3. <!-- Do not edit this file, it will be overwritten on install. 4. Copy the file to $HOME/.config/openbox/ instead. --> 5. <openbox_config xmlns="http://openbox.org/3.4/rc"> 6. <resistance> 7. <strength>10</strength> 8. <screen_edge_strength>20</screen_edge_strength> 9. </resistance> 10. <focus> 11. <focusNew>yes</focusNew> 12. <!-- always try to focus new windows when they appear. other rules do 13. apply --> 14. <followMouse>no</followMouse> 15. <!-- move focus to a window when you move the mouse into it --> 16. <focusLast>yes</focusLast> 17. <!-- focus the last used window when changing desktops, instead of the one 18. under the mouse pointer. when followMouse is enabled --> 19. <underMouse>no</underMouse> 20. <!-- move focus under the mouse, even when the mouse is not moving --> 21. <focusDelay>200</focusDelay> 22. <!-- when followMouse is enabled, the mouse must be inside the window for 23. this many milliseconds (1000 = 1 sec) before moving focus to it --> 24. <raiseOnFocus>no</raiseOnFocus> 25. <!-- when followMouse is enabled, and a window is given focus by moving the 26. mouse into it, also raise the window --> 27. </focus> 28. <placement> 29. <policy>Smart</policy> 30. <!-- 'Smart' or 'UnderMouse' --> 31. <center>yes</center> 32. <!-- whether to place windows in the center of the free area found or 33. the top left corner --> 34. <monitor>Any</monitor> 35. <!-- with Smart placement on a multi-monitor system, try to place new windows 36. on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where 37. the active window is --> 38. <primaryMonitor/> 39. </placement> 6 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... 40. <theme> 41. <name>TraditionalOk</name> 42. <titleLayout>NLIMC</titleLayout> 43. <!-- 44. available characters are NDSLIMC, each can occur at most once. 45. N: window icon 46. L: window label (AKA title). 47. I: iconify 48. M: maximize 49. C: close 50. S: shade (roll up/down) 51. D: omnipresent (on all desktops). 52. --> 53. <keepBorder>yes</keepBorder> 54. <animateIconify>yes</animateIconify> 55. <font place="ActiveWindow"> 56. <name>sans</name> 57. <size>10</size> 58. <!-- font size in points --> 59. <weight>bold</weight> 60. <!-- 'bold' or 'normal' --> 61. <slant>normal</slant> 62. <!-- 'italic' or 'normal' --> 63. </font> 64. <font place="InactiveWindow"> 65. <name>sans</name> 66. <size>10</size> 67. <!-- font size in points --> 68. <weight>bold</weight> 69. <!-- 'bold' or 'normal' --> 70. <slant>normal</slant> 71. <!-- 'italic' or 'normal' --> 72. </font> 73. <font place="MenuHeader"> 74. <name>sans</name> 75. <size>10</size> 76. <!-- font size in points --> 77. <weight>normal</weight> 78. <!-- 'bold' or 'normal' --> 79. <slant>normal</slant> 80. <!-- 'italic' or 'normal' --> 81. </font> 82. <font place="MenuItem"> 83. <name>sans</name> 84. <size>10</size> 85. <!-- font size in points --> 86. <weight>normal</weight> 87. <!-- 'bold' or 'normal' --> 88. <slant>normal</slant> 89. <!-- 'italic' or 'normal' --> 90. </font> 91. <font place="ActiveOnScreenDisplay"> 92. <name/> 93. <size>8</size> 94. <weight/> 95. <slant/> 96. </font> 97. <font place="InactiveOnScreenDisplay"> 7 of 21 06/07/2020, 21:19 How to Add Custom Keybindings in Openbox | Daniel ... https://www.danielrosehill.co.il/myblog/how-to-add-c... 98. <name>Sans</name> 99. <size>8</size> 100. <weight/> 101. <slant/> 102. </font> 103. </theme> 104. <desktops> 105. <!-- this stuff is only used at startup, pagers allow you to change them 106. during a session 107. these are default values to use when other ones are not already set 108. by other applications, or saved in your session 109. use obconf if you want to change these without having to log out 110. and back in --> 111. <number>2</number> 112. <firstdesk>1</firstdesk> 113. <names> 114. <name>Work</name> 115. <name>Backups</name> 116. </names> 117. <popupTime>0</popupTime> 118. <!-- The number of milliseconds to show the popup for when switching 119. desktops. Set this to 0 to disable the popup. --> 120. </desktops> 121. <resize> 122. <drawContents>yes</drawContents> 123. <popupShow>Nonpixel</popupShow> 124. <!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) --> 125. <popupPosition>Center</popupPosition> 126. <!-- 'Center', 'Top', or 'Fixed' --> 127. <popupFixedPosition> 128. <!-- these are used if popupPosition is set to 'Fixed' --> 129.