It certainly couldn't hurt.

On 24 April 2015 at 18:15, Martin <[email protected]> wrote:
> I might do that. A good place would be
> https://github.com/qtile/qtile/blob/develop/docs/manual/config/keys.rst#lazy-functions
>
> I would like to describe all the commands from most layouts, so I would need
> to explore the available commands from the layouts using qsh first.
>
> Do you think the when command itself needs a python doc-string?
>
> On Thursday, April 23, 2015 at 4:54:15 PM UTC-4, Craig Barnes wrote:
>>
>> I had to use the source to find that nuget ;)
>>
>> I happened across it while figuring out how cmd works.
>>
>> https://github.com/qtile/qtile/blob/develop/libqtile/command.py#L280
>>
>> Please feel free to submit a doc-string ;-)
>>
>> On 23 April 2015 at 21:32, Martin <[email protected]> wrote:
>> > Excellent, it also makes a lot of sense to have this capability rather
>> > than
>> > to add a lot of funny code in the config.
>> >
>> > Is this knowledge included in the API or documentation?
>> >
>> > Best regards
>> >
>> >
>> > On Wednesday, April 22, 2015 at 6:40:20 PM UTC-4, Craig Barnes wrote:
>> >>
>> >> The capability already exists.  There is a when method to each of the
>> >> lazy.jayout functions which can be used to trigger for selected
>> >> layouts only.
>> >>
>> >> e.g.
>> >>
>> >>     # Multi function keys
>> >>     Key(
>> >>         [mod, "shift"], "space",
>> >>         lazy.layout.rotate().when('stack'),
>> >>         lazy.layout.flip().when('xmonad-tall'),
>> >>     ),
>> >>     Key(
>> >>         [mod, "shift"], "k",
>> >>         lazy.layout.shuffle_down().when('stack'),
>> >>         lazy.layout.shuffle_down().when('vert'),
>> >>         lazy.layout.shuffle_down().when('xmonad-tall'),
>> >>     ),
>> >>     Key(
>> >>         [mod, "shift"], "j",
>> >>         lazy.layout.shuffle_up().when('stack'),
>> >>         lazy.layout.shuffle_up().when('xmonad-tall'),
>> >>     ),
>> >>     Key(
>> >>         [mod, ctl], "l",
>> >>         lazy.layout.add().when('stack'),
>> >>         lazy.layout.increase_ratio().when('tile'),
>> >>         lazy.layout.maximize().when('xmonad-tall'),
>> >>     ),
>> >>     Key(
>> >>         [mod, ctl], "h",
>> >>         lazy.layout.delete().when('stack'),
>> >>         lazy.layout.decrease_ratio().when('tile'),
>> >>         lazy.layout.normalize().when('xmonad-tall'),
>> >>     ),
>> >>     Key(
>> >>         [mod, ctl], "k",
>> >>         lazy.layout.shrink().when('xmonad-tall'),
>> >>         lazy.layout.decrease_nmaster().when('tile'),
>> >>     ),
>> >>     Key(
>> >>         [mod, ctl], "j",
>> >>         lazy.layout.grow().when('xmonad-tall'),
>> >>         lazy.layout.increase_nmaster().when('tile'),
>> >>     ),
>> >>
>> >>
>> >> Hope this helps
>> >>
>> >> On 22 April 2015 at 22:56, Martin <[email protected]> wrote:
>> >> > I like to use different layouts for different purposes, but I do not
>> >> > wish to
>> >> > map a key to every single required layout command for all layouts.
>> >> > For
>> >> > instance, in the tile layout I often use the
>> >> > increase_ratio/decrease_ratio
>> >> > commands which are set to MOD+H, MOD+L
>> >> > These super-useful keys are however of no use in the other layouts
>> >> > and
>> >> > when
>> >> > I use those layouts I would like to map the keys to something else.
>> >> > What
>> >> > would be a sane way to do this?
>> >> >
>> >> > My suggested approach is:
>> >> > 1. Use subscribe.focus_change hook to detect a situation where the
>> >> > keys
>> >> > might need to change
>> >> > 2. Querry the layout_type / name of the current layout for the
>> >> > current
>> >> > window / current group / current screen
>> >> > 3. Overwrite the key-bindings with a static set common for all
>> >> > layouts
>> >> > and a
>> >> > dynamic part which depends on the particular layout.
>> >> >
>> >> > My first question is if the above is sane? I would call quite a few
>> >> > key
>> >> > changes, and also floating and dialog windows and pop-ups may be
>> >> > dangerous
>> >> > if not managed correctly.
>> >> >
>> >> > Second question is how to get it to work.
>> >> >
>> >> > I have tried implementing 1 and 2 in the code below, but it doesn't
>> >> > work:
>> >> >
>> >> > @hook.subscribe.focus_change
>> >> > def change_layout():
>> >> >     name = ????
>> >> >     if name == 'tile':
>> >> >        layout_tile()
>> >> >     elf name == 'max
>> >> >        layout_max()
>> >> >
>> >> > I cannot querry the name of the layout in a hook. What I can do is
>> >> >
>> >> > keys.append(
>> >> >     Key([mod], "f", lazy.function(function))
>> >> > )
>> >> > def function(qtile):
>> >> >         test = qtile.currentLayout.name
>> >> >
>> >> > This works just fine, but for the hook function neither of the below
>> >> > works:
>> >> >
>> >> > ###
>> >> >
>> >> > @hook.subscribe.focus_change
>> >> > def change_layout(window):
>> >> >     doens't work, if there is an argument in the function, the hook
>> >> > will
>> >> > not
>> >> > execute anything. This makes no sense to me.
>> >> >
>> >> > ###
>> >> >
>> >> > c = Client()
>> >> > @hook.subscribe.focus_change
>> >> > def change_layout():
>> >> >    name = c.currentLayout.name
>> >> >    name2 = c.this_makes_no_sense.name
>> >> >
>> >> > returns the string currentLayout. I can even get it to run
>> >> > c.this_makes_no_sense.name and get the string this_makes_no_sense as
>> >> > a
>> >> > result. That is insane.
>> >> >
>> >> > ###
>> >> > def test(qtile)
>> >> >      name = qtile.currentLayout.name
>> >> > @hook.subscribe.focus_change
>> >> > def change_layout():
>> >> >     lazy.function(test)
>> >> >
>> >> > will not call the function, but does not give any errors either.
>> >> >
>> >> > A problem I keep having is the API which I find insufficient for my
>> >> > needs.
>> >> > The only way for me to find the commands I need is by browsing this
>> >> > google
>> >> > group and look for whatever I can find. For instance, there is no
>> >> > place
>> >> > where the currentLayout method or property is mentioned in the
>> >> > documentation. I cannot find it in the qsh shell either and I am too
>> >> > much of
>> >> > a noob to search the source code (I have tried, but the code is
>> >> > gibberish to
>> >> > me). The documentation keeps refering to the qsh, but the commands in
>> >> > there
>> >> > are of limited use. For instance, the qsh doesn't contain a command
>> >> > to
>> >> > querry information about the current layout, but the object passed by
>> >> > lazy.function (I guess it is an instance of Qtile?) have a
>> >> > currentLayout
>> >> > command which works.
>> >> >
>> >> > My rant seems to be that there is no api for the Client() object, nor
>> >> > the
>> >> > object passed by lazy, but these objects contain usefull methods
>> >> > which
>> >> > are
>> >> > unavailable in qsh.
>> >> >
>> >> > Oddly enough, I cannot get the commands in qsh to work either. I
>> >> > should
>> >> > be
>> >> > able to get the current layout by
>> >> > cd groups
>> >> > info
>> >> > get the 'layout' key value
>> >> >
>> >> > But the following command gives an exception
>> >> > c = Client()
>> >> > keys.append(
>> >> >     Key([mod], "f", lazy.function(test))
>> >> > )
>> >> > def test(qtile):
>> >> >         name = c.groups.info['layout']
>> >> >         # This doesn't work, because .info is a _Command object
>> >> >         # So is c.groups.insanity
>> >> >
>> >> > I also tried
>> >> > c = Client()
>> >> > test = c.group
>> >> > print(dir(test))
>> >> >
>> >> > to get a list of the methods in group, but there are hardly any and a
>> >> > command like print c.status() also doens't work, since it is also a
>> >> > _Command
>> >> > object.
>> >> >
>> >> > Sorry for a long rant, as I was writing this I kept getting ideas
>> >> > that I
>> >> > wanted to try out, but that didn't make me any less confused. I use a
>> >> > notify-send event to check when commands are being excecuted and
>> >> > print
>> >> > debug
>> >> > information this way. I catch any exception with a notify-send as
>> >> > well.
>> >> >
>> >> > I find the behaviour of my system rather strange. Is there something
>> >> > wrong
>> >> > with my Qtile installation or have I missed something critical?
>> >> >
>> >> > Any assistance is appreciated
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "qtile-dev" group.
>> >> > To unsubscribe from this group and stop receiving emails from it,
>> >> > send
>> >> > an
>> >> > email to [email protected].
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >>
>> >>
>> >>
>> >> --
>> >> Craig
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "qtile-dev" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [email protected].
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Craig
>
> --
> You received this message because you are subscribed to the Google Groups
> "qtile-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.



-- 
Craig

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to