bakkeby / patches

Collection of patches for dwm, st and dmenu
284 stars 30 forks source link

Flextile and inplacerotate question #17

Closed juacq97 closed 3 years ago

juacq97 commented 3 years ago

Hi! I have a question about the flextile layout. Flextile introduces the idea of a second stack, so I can put a "deck" layout on two stacks, that's awesome. Now there's this patch called inplacerotate instead of move the focus, the entire stack rotates, it's useful with the deck layout to not send windows to master. With two stacks though behaves weird (well, as expected) because if I rotate one stack the second stack rotates too, making a two stacks deck useless. There's a way to change the inplacerotate patch to respect my second stack?

On a second question of the flextile layout, there's a way to activate a specific split for stack/master without paas through every layout? For example to change the stack from vertical split to gapless grid. I know I can write a new layout and that's what I've done, but it'll be more flexible to toggle the desired split when I want. Thanks!!!

bakkeby commented 3 years ago

That's quite a few questions :)

The general answer is that it is dwm so almost anything is possible, it just depends on how far you are willing to go to get it.

Regarding inplacerotate, sure this is perfectly possible, but you'll have to have a flextile-deluxe aware version of the patch. You should in principle be able to take this version albeit with a few changes to make it compatible with a normal dwm (I think it is primarily ISFLOATING(c) --> c->isfloating that you need to change or set up a macro for).

On a second question of the flextile layout, there's a way to activate a specific split for stack/master without paas through every layout?

There is the rotatelayoutaxis function where you can rotate through the available split options and arrange methods per area.

https://github.com/bakkeby/patches/blob/0ca7cc3039fd0d959da2bce2dc76c138f1242bbd/dwm/dwm-pertag-flextile_deluxe-6.2.diff#L86-L94

The default keybindings are not great I know.

What you can also do is set the desired split / arrange option via the fsignal or the IPC patch.

Here is an example integrating this in an xmenu script:

image

If you want to pursue something like this then let me know and I'll give you some pointers.

juacq97 commented 3 years ago

Thanks!! I have been working on the inplacerotate patch (I sucks for C). I changed the ISFLOATING(c) for (c->isfloating)andISFLOATING(m->sel)form->sel->isfloating. I get an error about theiscenteredlayout(m, n)andisdualstacklayout(m)` functions. I cheked out the flextile patch and there's nothing like that, I checked the dawn repo and it seems to be a specific function written for it, so do you have an idea of how I can replace those functions?

If you want to pursue something like this then let me know

I want!, not a menu maybe, but a keybinding to toggle the most used splits. The logic behind your script should be similar (dwm-msg commands I suppose).

bakkeby commented 3 years ago

Yes sorry I have quite a range of changes in my personal build, these should be the droids you are looking for:

https://github.com/bakkeby/dawn/blob/274b83a16de7878b6fcb3eef67dd691667373174/patch/bar_flexwintitle.c#L155-L190

I'm pretty sure you can just copy-paste those as-is.

I used a function like this for external scripts (via fsignal, dwmc or the IPC patch):

https://github.com/bakkeby/dwm-flexipatch/blob/acbf2de1c23085e0a8736498e5c7600f77f7a5f0/patch/layout_flextile-deluxe.c#L70-L87

You can either use that as-is or simplify it to your needs.

Here is my menu script which you can use as a reference for the numbers you pass in to this function for the desired behaviour.

$ cat layoutmenu
#!/bin/sh

bind_layout() {
    cat << EOF | sed "s/#INDENT#/$1/"
#INDENT#Layout
#INDENT#    tile    dawnc run_command setlayoutex 0
#INDENT#    columns dawnc run_command setlayoutex 1
#INDENT#    rows    dawnc run_command setlayoutex 2
#INDENT#    monocle dawnc run_command setlayoutex 3
#INDENT#    col dawnc run_command setlayoutex 4
#INDENT#    floating master dawnc run_command setlayoutex 5
#INDENT#    deck    dawnc run_command setlayoutex 6
#INDENT#    bstack  dawnc run_command setlayoutex 7
#INDENT#    bstackhoriz dawnc run_command setlayoutex 8
#INDENT#    bstackgrid  dawnc run_command setlayoutex 9
#INDENT#    centeredmaster  dawnc run_command setlayoutex 10
#INDENT#    centeredmaster horiz    dawnc run_command setlayoutex 11
#INDENT#    gappless grid   dawnc run_command setlayoutex 12
#INDENT#    fibonacci dwindle   dawnc run_command setlayoutex 13
#INDENT#    fibonacci spiral    dawnc run_command setlayoutex 14
#INDENT#    floating layout dawnc run_command setlayoutex 15
#INDENT#Flextile
#INDENT#    Split
#INDENT#        No Split    dawnc run_command setlayoutaxisex 0
#INDENT#        Vertical    dawnc run_command setlayoutaxisex 4
#INDENT#        Horizontal  dawnc run_command setlayoutaxisex 8
#INDENT#        Centered Vertical   dawnc run_command setlayoutaxisex 12
#INDENT#        Centered Horizontal dawnc run_command setlayoutaxisex 16
#INDENT#        Vertical Dual Stack dawnc run_command setlayoutaxisex 20
#INDENT#        Horizontal Dual Stack   dawnc run_command setlayoutaxisex 24
#INDENT#        Floating Master dawnc run_command setlayoutaxisex 28
#INDENT#        Fixed Vertical  dawnc run_command setlayoutaxisex 32
#INDENT#        Fixed Horizontal    dawnc run_command setlayoutaxisex 36
#INDENT#        Fixed Centered Vertical dawnc run_command setlayoutaxisex 40
#INDENT#        Fixed Centered Horizontal   dawnc run_command setlayoutaxisex 44
#INDENT#        Fixed Vertical Dual Stack   dawnc run_command setlayoutaxisex 48
#INDENT#        Fixed Horizontal Dual Stack dawnc run_command setlayoutaxisex 52
#INDENT#        Fixed Floating Master   dawnc run_command setlayoutaxisex 56
#INDENT#    Master
#INDENT#        Top To Bottom   dawnc run_command setlayoutaxisex 1
#INDENT#        Left To Right   dawnc run_command setlayoutaxisex 5
#INDENT#        Monocle dawnc run_command setlayoutaxisex 9
#INDENT#        Gapplessgrid    dawnc run_command setlayoutaxisex 13
#INDENT#        Gapplessgrid Alt1   dawnc run_command setlayoutaxisex 17
#INDENT#        Gapplessgrid Alt2   dawnc run_command setlayoutaxisex 21
#INDENT#        Gridmode    dawnc run_command setlayoutaxisex 25
#INDENT#        Horizgrid   dawnc run_command setlayoutaxisex 29
#INDENT#        Fibonacci Dwindle   dawnc run_command setlayoutaxisex 33
#INDENT#        Fibonacci Spiral    dawnc run_command setlayoutaxisex 37
#INDENT#    Stack1
#INDENT#        Top To Bottom   dawnc run_command setlayoutaxisex 2
#INDENT#        Left To Right   dawnc run_command setlayoutaxisex 6
#INDENT#        Monocle dawnc run_command setlayoutaxisex 10
#INDENT#        Gapplessgrid    dawnc run_command setlayoutaxisex 14
#INDENT#        Gapplessgrid Alt1   dawnc run_command setlayoutaxisex 18
#INDENT#        Gapplessgrid Alt2   dawnc run_command setlayoutaxisex 22
#INDENT#        Gridmode    dawnc run_command setlayoutaxisex 26
#INDENT#        Horizgrid   dawnc run_command setlayoutaxisex 30
#INDENT#        Fibonacci Dwindle   dawnc run_command setlayoutaxisex 34
#INDENT#        Fibonacci Spiral    dawnc run_command setlayoutaxisex 38
#INDENT#    Stack2
#INDENT#        Top To Bottom   dawnc run_command setlayoutaxisex 3
#INDENT#        Left To Right   dawnc run_command setlayoutaxisex 7
#INDENT#        Monocle dawnc run_command setlayoutaxisex 11
#INDENT#        Gapplessgrid    dawnc run_command setlayoutaxisex 15
#INDENT#        Gapplessgrid Alt1   dawnc run_command setlayoutaxisex 19
#INDENT#        Gapplessgrid Alt2   dawnc run_command setlayoutaxisex 23
#INDENT#        Gridmode    dawnc run_command setlayoutaxisex 27
#INDENT#        Horizgrid   dawnc run_command setlayoutaxisex 31
#INDENT#        Fibonacci Dwindle   dawnc run_command setlayoutaxisex 35
#INDENT#        Fibonacci Spiral    dawnc run_command setlayoutaxisex 39
#INDENT#    Mirror Layout   dawnc run_command mirrorlayout
#INDENT#Gaps
#INDENT#    Presets
#INDENT#        No gaps (0px)   dawnc run_command setgaps 0
#INDENT#    Inner
#INDENT#        Horizontal
#INDENT#            0px dawnc run_command setgaps 2155872384
#INDENT#            1px dawnc run_command setgaps 2155872640
#INDENT#            2px dawnc run_command setgaps 2155872896
#INDENT#            3px dawnc run_command setgaps 2155873152
#INDENT#            4px dawnc run_command setgaps 2155873408
#INDENT#            5px dawnc run_command setgaps 2155873664
#INDENT#            10px    dawnc run_command setgaps 2155874944
#INDENT#            15px    dawnc run_command setgaps 2155876224
#INDENT#            20px    dawnc run_command setgaps 2155877504
#INDENT#            25px    dawnc run_command setgaps 2155878784
#INDENT#            30px    dawnc run_command setgaps 2155880064
#INDENT#            35px    dawnc run_command setgaps 2155881344
#INDENT#            40px    dawnc run_command setgaps 2155882624
#INDENT#            45px    dawnc run_command setgaps 2155883904
#INDENT#            50px    dawnc run_command setgaps 2155885184
#INDENT#        Vertical
#INDENT#            0px dawnc run_command setgaps 2155905024
#INDENT#            1px dawnc run_command setgaps 2155905025
#INDENT#            2px dawnc run_command setgaps 2155905026
#INDENT#            3px dawnc run_command setgaps 2155905027
#INDENT#            4px dawnc run_command setgaps 2155905028
#INDENT#            5px dawnc run_command setgaps 2155905029
#INDENT#            10px    dawnc run_command setgaps 2155905034
#INDENT#            15px    dawnc run_command setgaps 2155905039
#INDENT#            20px    dawnc run_command setgaps 2155905044
#INDENT#            25px    dawnc run_command setgaps 2155905049
#INDENT#            30px    dawnc run_command setgaps 2155905054
#INDENT#            35px    dawnc run_command setgaps 2155905059
#INDENT#            40px    dawnc run_command setgaps 2155905064
#INDENT#            45px    dawnc run_command setgaps 2155905069
#INDENT#            50px    dawnc run_command setgaps 2155905074
#INDENT#        No inner gaps (0px) dawnc run_command setgaps 2155872256
#INDENT#        1px dawnc run_command setgaps 2155872513
#INDENT#        2px dawnc run_command setgaps 2155872770
#INDENT#        3px dawnc run_command setgaps 2155873027
#INDENT#        4px dawnc run_command setgaps 2155873284
#INDENT#        5px dawnc run_command setgaps 2155873541
#INDENT#        10px    dawnc run_command setgaps 2155874826
#INDENT#        15px    dawnc run_command setgaps 2155876111
#INDENT#        20px    dawnc run_command setgaps 2155877396
#INDENT#        25px    dawnc run_command setgaps 2155878681
#INDENT#        30px    dawnc run_command setgaps 2155879966
#INDENT#        35px    dawnc run_command setgaps 2155881251
#INDENT#        40px    dawnc run_command setgaps 2155882536
#INDENT#        45px    dawnc run_command setgaps 2155883821
#INDENT#        50px    dawnc run_command setgaps 2155885106
#INDENT#    Outer
#INDENT#        Horizontal
#INDENT#            0px dawnc run_command setgaps 8421504
#INDENT#            1px dawnc run_command setgaps 25198720
#INDENT#            2px dawnc run_command setgaps 41975936
#INDENT#            3px dawnc run_command setgaps 58753152
#INDENT#            4px dawnc run_command setgaps 75530368
#INDENT#            5px dawnc run_command setgaps 92307584
#INDENT#            10px    dawnc run_command setgaps 176193664
#INDENT#            15px    dawnc run_command setgaps 260079744
#INDENT#            20px    dawnc run_command setgaps 343965824
#INDENT#            25px    dawnc run_command setgaps 427851904
#INDENT#            30px    dawnc run_command setgaps 511737984
#INDENT#            35px    dawnc run_command setgaps 595624064
#INDENT#            40px    dawnc run_command setgaps 679510144
#INDENT#            45px    dawnc run_command setgaps 763396224
#INDENT#            50px    dawnc run_command setgaps 847282304
#INDENT#        Vertical
#INDENT#            0px dawnc run_command setgaps 2147516544
#INDENT#            1px dawnc run_command setgaps 2147582080
#INDENT#            2px dawnc run_command setgaps 2147647616
#INDENT#            3px dawnc run_command setgaps 2147713152
#INDENT#            4px dawnc run_command setgaps 2147778688
#INDENT#            5px dawnc run_command setgaps 2147844224
#INDENT#            10px    dawnc run_command setgaps 2148171904
#INDENT#            15px    dawnc run_command setgaps 2148499584
#INDENT#            20px    dawnc run_command setgaps 2148827264
#INDENT#            25px    dawnc run_command setgaps 2149154944
#INDENT#            30px    dawnc run_command setgaps 2149482624
#INDENT#            35px    dawnc run_command setgaps 2149810304
#INDENT#            40px    dawnc run_command setgaps 2150137984
#INDENT#            45px    dawnc run_command setgaps 2150465664
#INDENT#            50px    dawnc run_command setgaps 2150793344
#INDENT#        No outer gaps (0px) dawnc run_command setgaps 32896
#INDENT#        1px dawnc run_command setgaps 16875648
#INDENT#        2px dawnc run_command setgaps 33718400
#INDENT#        3px dawnc run_command setgaps 50561152
#INDENT#        4px dawnc run_command setgaps 67403904
#INDENT#        5px dawnc run_command setgaps 84246656
#INDENT#        10px    dawnc run_command setgaps 168460416
#INDENT#        15px    dawnc run_command setgaps 252674176
#INDENT#        20px    dawnc run_command setgaps 336887936
#INDENT#        25px    dawnc run_command setgaps 421101696
#INDENT#        30px    dawnc run_command setgaps 505315456
#INDENT#        35px    dawnc run_command setgaps 589529216
#INDENT#        40px    dawnc run_command setgaps 673742976
#INDENT#        45px    dawnc run_command setgaps 757956736
#INDENT#        50px    dawnc run_command setgaps 842170496
#INDENT#    Both
#INDENT#        Horizontal
#INDENT#            0px dawnc run_command setgaps 8388736
#INDENT#            1px dawnc run_command setgaps 25166208
#INDENT#            2px dawnc run_command setgaps 41943680
#INDENT#            3px dawnc run_command setgaps 58721152
#INDENT#            4px dawnc run_command setgaps 75498624
#INDENT#            5px dawnc run_command setgaps 92276096
#INDENT#            10px    dawnc run_command setgaps 176163456
#INDENT#            15px    dawnc run_command setgaps 260050816
#INDENT#            20px    dawnc run_command setgaps 343938176
#INDENT#            25px    dawnc run_command setgaps 427825536
#INDENT#            30px    dawnc run_command setgaps 511712896
#INDENT#            35px    dawnc run_command setgaps 595600256
#INDENT#            40px    dawnc run_command setgaps 679487616
#INDENT#            45px    dawnc run_command setgaps 763374976
#INDENT#            50px    dawnc run_command setgaps 847262336
#INDENT#        Vertical
#INDENT#            0px dawnc run_command setgaps 2147516416
#INDENT#            1px dawnc run_command setgaps 2147581953
#INDENT#            2px dawnc run_command setgaps 2147647490
#INDENT#            3px dawnc run_command setgaps 2147713027
#INDENT#            4px dawnc run_command setgaps 2147778564
#INDENT#            5px dawnc run_command setgaps 2147844101
#INDENT#            10px    dawnc run_command setgaps 2148171786
#INDENT#            15px    dawnc run_command setgaps 2148499471
#INDENT#            20px    dawnc run_command setgaps 2148827156
#INDENT#            25px    dawnc run_command setgaps 2149154841
#INDENT#            30px    dawnc run_command setgaps 2149482526
#INDENT#            35px    dawnc run_command setgaps 2149810211
#INDENT#            40px    dawnc run_command setgaps 2150137896
#INDENT#            45px    dawnc run_command setgaps 2150465581
#INDENT#            50px    dawnc run_command setgaps 2150793266
#INDENT#        No gaps (0px)   dawnc run_command setgaps 0
#INDENT#        1px dawnc run_command setgaps 16843009
#INDENT#        2px dawnc run_command setgaps 33686018
#INDENT#        3px dawnc run_command setgaps 50529027
#INDENT#        4px dawnc run_command setgaps 67372036
#INDENT#        5px dawnc run_command setgaps 84215045
#INDENT#        10px    dawnc run_command setgaps 168430090
#INDENT#        15px    dawnc run_command setgaps 252645135
#INDENT#        20px    dawnc run_command setgaps 336860180
#INDENT#        25px    dawnc run_command setgaps 421075225
#INDENT#        30px    dawnc run_command setgaps 505290270
#INDENT#        35px    dawnc run_command setgaps 589505315
#INDENT#        40px    dawnc run_command setgaps 673720360
#INDENT#        45px    dawnc run_command setgaps 757935405
#INDENT#        50px    dawnc run_command setgaps 842150450
#INDENT#    Default Gaps    dawnc run_command defaultgaps
#INDENT#    Toggle Gaps dawnc run_command togglegaps
EOF
}

# Allow the above menu to be sourced by other scripts by setting
# the SOURCE_MENU environment variable.
if [ -z $SOURCE_MENU ]; then
    eval $(bind_layout | xmenu)
fi

(dawnc is the same as dwm-msg here)

You don't have to use the IPC patch for this, you can also just add normal keybindings within dwm to run these.

juacq97 commented 3 years ago

Your function worked flawlesly! Now I'll bind my most needed layouts, thanks!!!