Editing files as root in Ubuntu

When I right-click a file in Ubuntu and say “Open in gedit” or “Open in bluefish” or whatever, if I don’t have rights to edit that file, I don’t want it to open it read-only. Instead, I want it to say “You don’t have rights to edit this file? Open it read-only or edit it as root?” and then, if I pick “edit it as root“, do “gksudo “, so that I can edit it and don’t have to drop to a command line to do it.
How can I do this? The only way I can think of doing it is to change all my “open this file with this application” things so that, instead of opening the file in the app, it opens them with a little zenity shell script that does what I want. That’s a massive pain in the arse to do. The problem is that you can’t hack Nautilus to do this for you,. because it doesn’t want to happen with applications that aren’t editors. Suggestions, anyone?

I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing and articles. You can take a look at some projects I've worked on and some of my writing. If you'd like to talk about your upcoming project, do get in touch.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)