pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.61k stars 200 forks source link

Macro support #396

Open johannes-darms opened 8 years ago

johannes-darms commented 8 years ago

I'd like to have the option to specify a key to start an "sync" command. I mostly work in ikhal modifying or reading events. Before or after that I quit ikhal start vidrsyncer and restart ikhal. This workflow isn’t that optimal. I could use a cronjob to sync any n minutes, but this isn't useful since mostly this cronjob wouldn't do anything, thus putting unnecessary load on the client and sever. Nobody is changing his calendar that often! Another option would be to wrap ikhal in a script which runs a sync before and after ikhal. Which does not solve the occasionally restarting of ikhal. A solution like mutts macros would be great, or a slimmed down version of that (like mutt's query_command ).

geier commented 8 years ago

Real macro support would probably involve a some refactoring (which I currently don't have time for).

But as this is probably a common workflow (it's mine too), supporting in with a bit of a hack is probably a good idea anyway. See #320 and #331 for related issues.

untitaker commented 8 years ago

Perhaps this is better solved by https://github.com/pimutils/vdirsyncer/issues/24? I.e. have a vdirsyncer daemon that just pushes new changes to the server.

If you really want the macro-thing, maybe you could launch khal in tmux and use tmux keybindings to launch sync?

johannes-darms commented 8 years ago

Perhaps this is better solved by pimutils/vdirsyncer#24? I.e. have a vdirsyncer daemon that just pushes new changes to the server.

This solution would have the same shortcomings as a cronjob. Most of the time the process will be idle. Another point is that users, who are using scp or some other tool to sync there vcards, cannot use this approach.

If you really want the macro-thing, maybe you could launch khal in tmux and use tmux keybindings to launch sync?

Yeah sure, I could use some external program for a macro. But then I need to restart ikhal anyhow since the update of the vcards isn't recognised.

Real macro support would probably involve a some refactoring (which I currently don't have time for).

I'm note sure if a 'real' macro thing is really needed. I just the term, since I couldn't find a better one. For me a simple solution is sufficient. One approach could be: Defining a shortcut and a command, and execute the command when the key is pressed. Afterwards the functions of #320 should be called.

sync_key="S" 
sync_key_command_="vdirsyncer sync"
johannes-darms commented 8 years ago

I did some work on this issue and hacked a keyListener in the classicView and added some configuration options (like in my previous post) . Sadly I cannot refresh the whole frame from there without some kind of event propagation. So I thought about implementing it as a 'global' command in the window Class. IMHO this solution is better one thus it would be easier to add other Views without much altering the code/changing the behaviour. Currently the configuration isn't present in that scope of the Window Class. Would it be feasible/wise to add the configuration to the Window Class Scope?

geier commented 8 years ago

Sure, feel free to pass around the config. In my opinion the current way of passing around parent objects to their own childs is much worse.