GithubHelp home page GithubHelp logo

Comments (29)

kristijanhusak avatar kristijanhusak commented on July 29, 2024 1

@hongphong177 I missed one spot that's not using proper function. I updated the docs, but only change is that utils on line 12 becomes require('orgmode.utils').

from orgmode.

hongphong177 avatar hongphong177 commented on July 29, 2024 1

it's worked thanks a lot @kristijanhusak

from orgmode.

mortezadadgar avatar mortezadadgar commented on July 29, 2024 1

@kristijanhusak yes indeed it does work sorry for noise

from orgmode.

Maltimore avatar Maltimore commented on July 29, 2024 1

I moved to lazy.nvim and use your partial orgmode cron file now. I can confirm that with your latest changes, everything works perfectly:

  • if an error occurs, I get notified of this now
  • the error itself doesn't occur anymore because you fixed the source of that

Furthermore, I also tested it with my previous approach and can confirm that even then (i.e. not using the partial config), it works. Thanks a lot!! :)

from orgmode.

hongphong177 avatar hongphong177 commented on July 29, 2024

image
I just try notification and get this error message

below is my setting:

notifications = {
        enabled = true,
        cron_enabled = false,
        repeater_reminder_time = {1, 5, 10},
        deadline_warning_reminder_time = {1, 5, 10},
        reminder_time = {1, 5, 10},
        deadline_reminder = true,
        scheduled_reminder = true,
        notifier = function(tasks)
          local result = {}
          for _, task in ipairs(tasks) do
            utils.concat(result, {
              string.format('# %s (%s)', task.category, task.humanized_duration),
              string.format('%s %s %s', string.rep('*', task.level), task.todo, task.title),
              string.format('%s: <%s>', task.type, task.time:to_string())
            })
          end
    
          if not vim.tbl_isempty(result) then
            require('orgmode.notifications.notification_popup'):new({ content = result })
          end
        end,
}

from orgmode.

levouh avatar levouh commented on July 29, 2024

I use these every day (rather than cron I've setup a systemd timer) and they work flawlessly.

from orgmode.

joshpetit avatar joshpetit commented on July 29, 2024

I've been using this with just the neovim notification and it works well! Especially with nvim-notify

from orgmode.

excalios avatar excalios commented on July 29, 2024

I tried it using the optimal way the service returned an error (I used systemd timer)
image

image
if I used my config it'll return this
image

this is my config:

  notifications = {
    enabled = true,
    cron_enabled = true,
    repeater_reminder_time = {0, 1, 5},
    deadline_warning_reminder_time = {0, 1, 5, 15, 30, 60},
    reminder_time = 10,
    deadline_reminder = true,
    scheduled_reminder = true,
    notifier = function(tasks)
      local result = {}
      for _, task in ipairs(tasks) do
        require('orgmode.utils').concat(result, {
          string.format('# %s (%s)', task.category, task.humanized_duration),
          string.format('%s %s %s', string.rep('*', task.level), task.todo, task.title),
          string.format('%s: <%s>', task.type, task.time:to_string())
        })
      end

      if not vim.tbl_isempty(result) then
        require('orgmode.notifications.notification_popup'):new({ content = result })
      end
    end,
    cron_notifier = function(tasks)
      for _, task in ipairs(tasks) do
        local title = string.format('%s (%s)', task.category, task.humanized_duration)
        local subtitle = string.format('%s %s %s', string.rep('*', task.level), task.todo, task.title)
        local date = string.format('%s: %s', task.type, task.time:to_string())

        if vim.fn.executable('notify-send') == 1 then
          vim.loop.spawn('notify-send', { args = { string.format('%s\n%s\n%s', title, subtitle, date) }})
        end
      end
    end
  },

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@excalios seems like you generally have something loaded incorrectly, because I see some indent line errors.
what does it happen if you do this:

ni --noplugin --headless -c "echo 'test' | qa"

from orgmode.

excalios avatar excalios commented on July 29, 2024

@kristijanhusak Thanks for the reply I ran the command and got this result:
image

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@excalios is your config working properly when you run it through regular neovim session?

from orgmode.

excalios avatar excalios commented on July 29, 2024

@kristijanhusak Seems to be working fine except the notifications? I'm unsure on how to test it

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@excalios set up a TODO that will happen in a bit more than 10 minutes. Open up Neovim and wait until exactly 10 minutes before the task deadline time, and it should show you a notification inside Neovim in top right corner.

from orgmode.

excalios avatar excalios commented on July 29, 2024

I managed to get it working-ish.
I upgraded my neovim apparently it was quite old version. Managed to run it with no error on this command
/usr/bin/nvim --headless --noplugin -c 'lua require("orgmode").cron(require("excalios.orgconf"))'
I moved the systemd timer from system dir to user dir. Apparently when it's on system it couldn't find the orgmode but on user it was able to find it. I didn't change the config from there.
But, the notification doesn't always popup sometimes it does more time it doesn't. I checked the handle and the pid it was able to create the process no problem. But, the notification just doesn't popup somehow. I tried adding another empty spawn it popped up more often but not always. Adding a spawn with a command in it made it to always popup but I don't like this approach. Might just be my setup thanks for the help though

from orgmode.

Tokubara avatar Tokubara commented on July 29, 2024

If we just add a SCHEDULED entry, do we need to do something to make it in effect?

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@Tokubara you should be getting both scheduled and deadline notifications.

from orgmode.

Maltimore avatar Maltimore commented on July 29, 2024

I'm only getting notifications for SCHEDULED (and possibly DEADLINE, didn't test), but not for plain timestamps. Is this on purpose?
In general I'm wondering whether I'm using plain timestamps properly, since there were a few other bugs with this in the past (and some issues I'll file soon). I'm using orgmode also as a calendar, and when I have a meeting scheduled, I make a headline entry with the meeting name and a plain timestamp to indicate the time. Is this not how org should be used?

from orgmode.

jgollenz avatar jgollenz commented on July 29, 2024

I'd say orgmode should be used how it fits your needs. I also use plain timestamps on things I just want on my agenda, like you do. This is what orgmode says about it. The difference, as far as the agenda is concerned (and I am aware of), is that scheduled items will continue to show up on the current day, until you set them to DONE archive them.

from orgmode.

Maltimore avatar Maltimore commented on July 29, 2024

All right, thanks for clarifying! :)
So I suppose it should be a bug then that headlines with just a plain timestamp don't shop up in the notifications. Should I file an issue?

from orgmode.

jgollenz avatar jgollenz commented on July 29, 2024

Not sure if bug or missing feature. Emacs orgmode also does not seem to have notifications built in. Feel free to open an issue 👍

from orgmode.

mortezadadgar avatar mortezadadgar commented on July 29, 2024

I can't make this feature to function at all i have a scheduled entry in a org file like this:

* Events
** Send notification now
   SCHEDULED: <2023-12-02 Sat 21:45>

running following command manually from command line I'm not getting any notification

/usr/bin/nvim --headless --noplugin -c 'lua require("orgmode").cron()'

notify-send is installed anything am i missing?

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@mortezadadgar what are your reminder settings? If you set reminder time to 10 it will show you the notification only if you run it exactly 10 minutes before the scheduled datetime. So for given todo, to see a notification, you need to run it at 2023-12-02 Sat 21:35, considering you are using correct configuration for corn, and a default reminder time which is 10.

from orgmode.

Maltimore avatar Maltimore commented on July 29, 2024

I've had cron notifications set up since a long time by now, and I haven't changed anything. However, the notifications recently stopped working. What's more, I have tons of stuck nvim processes that fill up my RAM.
I suspect that there's an error in one of my org files, which trips up the treesitter parser and leads to an error in the orgmode plugin. When I run the command in crontab manually, I get

$ DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /home/maltimore/programs/nvim --headless --noplugin -c 'lua require("orgmode").cron()'
Error executing vim.schedule lua callback: ...er/start/orgmode.nvim.git/lua/orgmode/files/headline.lua:307: attempt to index a nil value
stack traceback:
        ...er/start/orgmode.nvim.git/lua/orgmode/files/headline.lua:307: in function 'method'
        ...packer/start/orgmode.nvim.git/lua/orgmode/utils/init.lua:570: in function 'get_todo'
        ...er/start/orgmode.nvim.git/lua/orgmode/files/headline.lua:328: in function 'is_done'
        ...packer/start/orgmode.nvim.git/lua/orgmode/files/file.lua:455: in function <...packer/start/orgmode.nvim.git/lua/orgmode/files/file.lua:453>
        vim/shared.lua: in function 'method'
        ...packer/start/orgmode.nvim.git/lua/orgmode/utils/init.lua:570: in function 'get_opened_unfinished_headlines'
        ...tart/orgmode.nvim.git/lua/orgmode/notifications/init.lua:95: in function 'get_tasks'
        ...tart/orgmode.nvim.git/lua/orgmode/notifications/init.lua:65: in function 'cron'
        .../pack/packer/start/orgmode.nvim.git/lua/orgmode/init.lua:221: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

If my suspicion that there's an error in one of my orgfiles is correct, it would be great if orgmode could report the org file and line where the error occurs. And, ideally, report this as a notification.

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@Maltimore Removing --noplugin should make it work. This would load all the plugins though, but it should work.
I use a separate file where I load everything that's necessary for a cron and use it like this:

* * * * * DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus /home/kristijan/.local/share/bob/nvim-bin/nvim -u NONE --headless --noplugin -c 'lua require("partials.orgmode_cron")'

I can't recall how this managed to work with --noplugin since there is a dependency on nvim-treesitter.

Let me know if removing --noplugin works for you.

from orgmode.

Maltimore avatar Maltimore commented on July 29, 2024

Unfortunately, removing --noplugin does not work, I get the same error as before.

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

Can you try using my file I provided and see if that helps? What package manager are you using?

from orgmode.

Maltimore avatar Maltimore commented on July 29, 2024

I'm using packer for now. I wanted to migrate to lazy anyways, so I guess I'll do that now/soon and then use your partial lazy-based config and report back!

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

it would be great if orgmode could report the org file and line where the error occurs. And, ideally, report this as a notification.

I had these issues myself so I'll see to add some way to notify the user that something is failing

from orgmode.

kristijanhusak avatar kristijanhusak commented on July 29, 2024

@Maltimore I pushed some changes (4c7b539) that should properly exit and report errors via system notifier.
Also the error you got is something that can really happen (even though I didn't manage to reproduce it), so I also addressed that. Let me know if it works now.

from orgmode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.