joewing / jwm

Joe's Window Manager
http://joewing.net/projects/jwm
MIT License
520 stars 84 forks source link

Support: window management with keyboard shortcuts #511

Open graemeg opened 3 years ago

graemeg commented 3 years ago

I've been using JWM for years, and don't want to switch to something else. Recently for work, on my Mac I've been using Spectacle or Magnet so I can use keyboard shortcuts to position and size my application windows.

I know you get tiling window managers for Linux, like i3 etc. But then I loose a lot of what I like about JWM. Does JWM have support to position and size windows like Spectacle of Magnet for MacOS can do? That would be the ideal situation for me. I get to stay with JWM and can bind keyboard shortcuts to manage my application windows.

For reference, here are the MacOS apps I was referring too:

And here is how I configured my keyboard for Spectacle:

https://configure.ergodox-ez.com/ergodox-ez/layouts/q96az/latest/9

graemeg commented 3 years ago

Oh, good news! Seems JWM already supported most of what I wanted. I read through the man page and found some keyboard bindings I could use...

   <!-- Press any of these twice to restore to previous state --> 
   <!-- Left half -->
   <Key mask="A4" key="Left">maxleft</Key>
   <!-- Right half -->
   <Key mask="A4" key="Right">maxright</Key>
   <!-- Top half -->
   <Key mask="A4" key="Up">maxtop</Key>
   <!-- Bottom half -->
   <Key mask="A4" key="Down">maxbottom</Key>
   <!-- Just at the command says ;-)  -->
   <Key mask="A4" key="F">fullscreen</Key>

   <!-- Move to desktop on the right -->
   <Key mask="CA4" key="Right">sendr</Key>
   <!-- Move to desktop on the left -->
   <Key mask="CA4" key="Left">sendl</Key>

I binded them to the same shortcuts as I use with Spectacle for MacOS.

The only ones I am missing are the 1/3 and 2/3 horizontal sizing on left or right, and the 1/4 sizes for each corner of the desktop.

I don't know C programming, but will dig through the code. Maybe I can figure out how to add those myself, seeing that most of the functionality already exists.

jcowgar commented 2 years ago

You can use a tool such as xdotool to accomplish this for you. I have two monitors, 3840x2160. Accounting for border sizes, I came up with these shortcuts. They are roughly h and l are right and left 50% split. Two inners, j and k are a 40%/60%. These are for my lower monitor. For you upper monitor (physically sit one on top of the other), I use yuip keys to do the same thing.

  <!-- Upper Monitor -->
  <Key mask="4" key="u">exec:xdotool getactivewindow windowmove 0 0 windowsize 1904 100%</Key>
  <Key mask="4" key="i">exec:xdotool getactivewindow windowmove 0 0 windowsize 1530 100%</Key>
  <Key mask="4" key="o">exec:xdotool getactivewindow windowmove 1542 0 windowsize 2282 100%</Key>
  <Key mask="4" key="p">exec:xdotool getactivewindow windowmove 1928 0 windowsize 1904 100%</Key>

  <!-- Lower Monitor -->
  <Key mask="4" key="h">exec:xdotool getactivewindow windowmove 0 2160 windowsize 1904 100%</Key>
  <Key mask="4" key="j">exec:xdotool getactivewindow windowmove 0 2160 windowsize 1530 100%</Key>
  <Key mask="4" key="k">exec:xdotool getactivewindow windowmove 1542 2160 windowsize 2282 100%</Key>
  <Key mask="4" key="l">exec:xdotool getactivewindow windowmove 1928 2160 windowsize 1904 100%</Key>