简体   繁体   中英

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

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 withGLib.spawn_command_line_async() , although I always prefer GSubprocess myself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM