0xFR
0xFR

Reputation: 118

Create a GNOME shell extension that enables and disables the webcam

I would like to create a shell extension for Ubuntu 20.04 that enables and disables the webcam but I don't know absolutely anything about JavaScript. Although, the extension is pretty simple: I would like to make a simple camera icon in the top bar that

  1. When clicked on just becomes crossed out and executes sudo modprobe -r uvcvideo, to disable the webcam.
  2. When then re-clicked on just runs sudo modprobe uvcvideo and the icon returns to the one before, enabling the webcam.

How can I do it?

EDIT: I made it by myself in GO, if you're searching for it here it is https://github.com/0xfederama/simple-tasks

Upvotes: 3

Views: 462

Answers (1)

andy.holmes
andy.holmes

Reputation: 3696

You should probably start by looking through the tutorial on the GNOME Wiki:

https://wiki.gnome.org/Projects/GnomeShell/Extensions/Writing

When spawning your command, you're probably going to want to use pkexec instead of sudo. I wouldn't recommend doing anything requiring superuser access in an extension, but pkexec will at least work properly in a GUI environment.

To spawn your command, you can probably get away with GLib.spawn_command_line_async(), although I always prefer GSubprocess myself.

Upvotes: 2

Related Questions