nh icon indicating copy to clipboard operation
nh copied to clipboard

Ask for sudo on the start

Open Acisama opened this issue 1 year ago • 10 comments

Is there some way to make it so it asks for the password at the start of the upgrade?

Because if you download many things it takes a while and sometimes I just want to do other stuff during that time, but sudo times out after 30 seconds. Or can I use some other method to achieve this?

Acisama avatar Dec 29 '24 09:12 Acisama

nh os switch --ask or sudo nh os switch -R

viperML avatar Dec 29 '24 09:12 viperML

I think the best solution would just be to send a notification. This was originally stated in this comment as to be done in #107 but that obviously never happened. Can this idea be revisited?

HirschBerge avatar Jan 03 '25 06:01 HirschBerge

The notification should be triggered for long builds (e.g longer than 60s) and use some cross-platform crate that supports darwin

viperML avatar Jan 03 '25 11:01 viperML

Not sure if you were actually asking for recommendations, or just jotting it down for future, but notify seems to fit the criteria.

Specifically mentions that it was originally targeted for darwin. I've used it in small personal projects and it works well.

HirschBerge avatar Jan 04 '25 01:01 HirschBerge

PR's are welcome

viperML avatar Jan 04 '25 07:01 viperML

Can you point me in the direction of the correct portion of the code base. I can take a look when I have time.

HirschBerge avatar Jan 05 '25 00:01 HirschBerge

Would love this, especially as just sudo'ing it is unsupported

CuboidRaptor avatar Jan 28 '25 01:01 CuboidRaptor

I also would love this :) a notification would be neat, since i personally have 0 xp with rust i think i would break it trying to do it ^^

hellconnon avatar Apr 30 '25 12:04 hellconnon

This would be nice, I have been doing sudo echo ; nh os switch to get around this

Yeshey avatar Aug 07 '25 20:08 Yeshey

I think I might be able to add a --notify flag (and NH_NOTIFY to set the flag via env) so that it sends notifications when

  1. Sudo password is prompted
  2. the switch command is done

Alternatively I can switch this into two environment variables (NH_SUDO_NOTIFY and NH_SWITCH_NOTIFY or similar), which would be both implied by the --notify flag. I understand that this issue is about notifications for sudo specifically, however, there might be more value in a fine-grained notification system in order to justify the dependency cost of something like the notify crate. Feedback is welcome, I'll try to submit a PR this evening for those willing to test.

NotAShelf avatar Aug 08 '25 04:08 NotAShelf