Closed CRAG666 closed 2 years ago
That looks really great, improving newm-cmd
is something we should do.
Just two minor thoughts that popped into my head:
cmd.py
, finish-inhibit-idle
is not something we should expose as newm-cmd finish-inhibit-idle
but rather as part of newm-cmd inhibit-idle
. Also there is newm-cmd launcher <app>
(this one is used by newm-panel-basic launcher
).lock-pre
and lock-post
from layout.py
, nobody uses them."unlock": {
"help": "Unlocks the screen",
"args": {}
}
That might work, I'll commit and try this
@jbuchermn I already made the change with the suggestions you gave me. Now it only remains for me to review what I did, any suggestion is welcome
These are the commands you exposed in newm-cmd, In the future, I could add/remove commands in this dictionary:
commands: dict[str, dict[str, Union[str, dict[str, str]]]] = {
"inhibit-idle": {
"help": "Prevents newm from going into idle states (dimming the screen)",
"args": {},
},
"config": {
"help": "Reloads the configuration",
"args": {},
},
"lock": {
"help": "Locks the screen",
"args": {},
},
"clean": {
"help": "Removes orphaned states, which can happen, but shouldn't (if you encounter the need for this, please file a bug)",
"args": {},
},
"debug": {
"help": "Prints out some debug info on the current state of views",
"args": {},
},
"unlock": {
"help": "Unlocks the screen",
"args": {},
},
"open-virtual-output": {
"help": "opens a new virtual output (see newm-sidecar)",
"args": {"output_name": "newm-cmd open-virtual-output <name>"},
},
"close-virtual-output": {
"help": "close a virtual output",
"args": {"output_name": "newm-cmd close-virtual-output <name>"},
},
}
@jbuchermn is the args parameter a tuple or a dictionary? I ask because I want to include in this pr the deletion of lock-pre and lock-post, but I also wanted to send parameters to lock
def command(self, cmd: str, arg: Optional[str] = None) -> Optional[str]:
These are the commands you exposed in newm-cmd, In the future, I could add/remove commands in this dictionary:
commands: dict[str, dict[str, Union[str, dict[str, str]]]] = { "inhibit-idle": { "help": "Prevents newm from going into idle states (dimming the screen)", "args": {}, }, "config": { "help": "Reloads the configuration", "args": {}, }, "lock": { "help": "Locks the screen", "args": {}, }, "clean": { "help": "Removes orphaned states, which can happen, but shouldn't (if you encounter the need for this, please file a bug)", "args": {}, }, "debug": { "help": "Prints out some debug info on the current state of views", "args": {}, }, "unlock": { "help": "Unlocks the screen", "args": {}, }, "open-virtual-output": { "help": "opens a new virtual output (see newm-sidecar)", "args": {"output_name": "newm-cmd open-virtual-output <name>"}, }, "close-virtual-output": { "help": "close a virtual output", "args": {"output_name": "newm-cmd close-virtual-output <name>"}, }, }
This looks really good - in my personal opinion a lot cleaner than before.
Could you please add newm-cmd launcher <app>
?
@jbuchermn is the args parameter a tuple or a dictionary? I ask because I want to include in this pr the deletion of lock-pre and lock-post, but I also wanted to send parameters to lock
def command(self, cmd: str, arg: Optional[str] = None) -> Optional[str]:
You mean in this method? It's just a string. See cmd.py
for the relevant line:
result = send_dbus_command({'cmd': command, 'arg': " ".join(args)})
The args
tuple passed to the cmd
method is joined to one string, passed via dbus, and then passed to Layout.command
as the second argument.
@jbuchermn Including newm-cmd launcher
@jbuchermn Including newm-cmd launcher
seems sensible to me, I'm working on that right now. Second, as for ensure_locked, it receives keyword, so how did this happen, that is, from what I saw, it receives key parameters value something like ensure_locked(dim=True). How I do this?
You mean, we should implement newm-cmd lock dim
and newm-cmd lock
(or similar) to give users the ability to either dim or not? I think that's a good idea. Wen can just do ensure_locked(arg == "dim")
@jbuchermn Including newm-cmd launcher seems sensible to me, I'm working on that right now. Second, as for ensure_locked, it receives keyword, so how did this happen, that is, from what I saw, it receives key parameters value something like ensure_locked(dim=True). How I do this?
You mean, we should implement
newm-cmd lock dim
andnewm-cmd lock
(or similar) to give users the ability to either dim or not? I think that's a good idea. Wen can just doensure_locked(arg == "dim")
Yesterday I realized this. You're right. Everything is already implemented. I hope and you can accept the pr
@jbuchermn Any changes that I should add? or else it only remains to merge.
Nice work, thank you! :)
Just fyi - I added a commit fixing the typing and adding "update-config" command
@jbuchermn Good to see this is already merged. That change seems more sensible to me
I rewrote newm-cmd, in order to make it behave like a common terminal tool (showing help, error detection, suggestions). Any suggestions are welcome, I also want to modify newm-panel-basic, but I still have to read how it works, if you want to add another command add the respective subcommand in the command_without_args or command_needs_args variables, depending if it needs arguments or not.