olemartinorg / i3-alternating-layout

Scripts to open new windows in i3wm using alternating layouts (splith/splitv) for each new window
MIT License
350 stars 41 forks source link

Add toggling of alternating layout #5

Closed secar closed 8 years ago

secar commented 8 years ago

Hello friend. I've been using this script for a while and I wanted a way to toggle it with a single key like you toggle the other layouts in i3.

This way I can simply do in my config file:

bindsym $mod+f exec --no-startup-id ~/.i3/alternating_layouts.py

I don't know how to use i3's python module, so simply switching to another layout doesn't terminate the script. You have to press the assigned key again (rerun the script).

Hope you find it to be a good idea!

olemartinorg commented 8 years ago

Also, let's say you have the following setup:

bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
bindsym $mod+f exec --no-startup-id ~/.i3/alternating_layouts.py

Why not just (probably not fully working, but you get the idea) do this:

bindsym $mod+s exec --no-startup-id killall ~/.i3/alternating_layouts.py; layout stacking
bindsym $mod+w exec --no-startup-id killall ~/.i3/alternating_layouts.py; layout tabbed
bindsym $mod+e exec --no-startup-id killall ~/.i3/alternating_layouts.py; layout toggle split
bindsym $mod+f exec --no-startup-id ~/.i3/alternating_layouts.py
secar commented 8 years ago

(one month later) Hello again! Sorry but I was uselessly busy. Anyway your criticism is absolutely correct. eval() was a bad school habit The solution you described with killall works. If you prefer to manage that in the config file, that makes sense too but I did a simple 2 liner solution. I'll pull request it. Feel free to ignore it, obviously.

olemartinorg commented 8 years ago

Hi again! :-) Actually, i had forgotten all about this. If you look at #7, I added a pid-file option, you could probably expand on that?

secar commented 8 years ago

Okay certainly, I'll look into it!