Optimus-Switch Indicator Extension for Gnome

Ever since I started using @dglt's Optimus-Switch, I wanted a graphical way to not only switch between the two cards, but a visual indicator showing what card I am using. I found a Gnome extension that worked with Ubuntu and wondered if I could adapt it to work with Optimus-Switch on Manjaro. After a couple of days of experimentation and learning, I am proud to announce that I have been successful.

Introducing Optimus-Switch-Argos-Manjaro

It uses the "Argos" extension that allows one to use bash scripts to create extensions for Gnome. This will allow the user to not only switch between the nVidia and Intel graphics cards, but gives a visual indication of which graphics card is in use by a tray icon. Installation instructions are included in the readme.

Showing that the Intel Integrated Graphics is in use.

optimus-switcher-intel

Showing that the nVidia GPU, and its temperature, is in use.

optimus-switcher-nvidia

I had fun working on this project and I hope some of you find this useful.

9 Likes

nicely done, if i had any storage available i would install gnome just to try it. i have to do some drive cleaning or better yet just order another ssd.

im way out of my depth when it comes to GUI's but i would like to have one available for all three optimus-switch versions (gdm/lightdm/sddm) eventually. :+1:

2 Likes

Thank you. Luckily, the Argos Extension handles the GUI part. I just had to focus on the bash script. Since I am still learning how bash scripts work, much trial and error, research, and swearing was done.

3 Likes

This is awesome. I don't use Gnome or an Optimus laptop, but I think it's fantastic the way you guys have added these new options for Manjaro users. It really showcases how vibrant and helpful the Manjaro community is.

Great work @linesma & @dglt, kudos to you both.

3 Likes

I noticed optimus manager has a similar Qt app for it. Perhaps some enterprising individual could use it as a basis to create similar for optimus-switch.

@linesma would you mind if I moved this to the newly created Manjaro development sub-forum.

Here's the link to the Qt app:

1 Like

@tbg Feel free to move it. Thanks!

1 Like

5 posts were split to a new topic: An alternative solution for optimus indicators

Please keep the discussion focused on the issue at hand.

Thanks!

1 Like

With some help from @petsam, I was able to clean up and simplify how the script detects what graphics card is in use. The extension is now "install and go" for the end user.

I will be working on a "sibling" version of this extension that will also show the temperature of the Intel card when it is in use. Why? So I can try to apply some of knowledge that I learned.

Once again, thank you @petsam for your help, I truly do appreciate it.

2 Likes

@linesma: This is awesome! Is this stable and working?

Yes it is stable and working. I am using it every day.

1 Like

Great. I will give it a try.

I went to install Argos, but for some reason the Gnome-Firefox extension isn't working for me. I'll have to figure that out first.

@shockwave Sorry it took me so long to reply. I missed the notification that you had posted. Were you able to figure out your problem with the Firefox Extension? If not, you can always install the Firefox extension directly from Firefox's Addon site:

Make sure that you log into the Gnome Extensions website as well. If that still does not work, you can also install the Argos extension manually. They have directions on how to do it on their GitHub page.

I have had the problem with the Firefox extension as well. Sometimes restarting my computer worked, others I had to just install the extension I wanted for Gnome manually. They then updated when through the "Tweaks" program.

1 Like

I wasn't able to make it work yet. I'll take a look at the links you sent. and see if I can get it working and report back.

I was finally able to get the gnome extension to work by allowing in private window, and got argos installed.

However, I am stuck on this step:

cp -v icons/* ~/.local/share/icons/

I get the following error

cp: failed to access '/home/workstation0/.local/share/icons/': Not a directory

If I do sudo nano ~/.local/share/icons the file is there and contains

! [ -d "~/.local/share/icons" ] && mkdir --parents ~/.local/share/icons || trueg

Is there something I am missing/doing wrong?

Oh, I think I see the issue, This line of code is to create the directory not what to put in it. I removed what I created and started over a again.

! [ -d "~/.local/share/icons" ] && mkdir --parents ~/.local/share/icons || trueg

I then went through the steps as posted, but I have no new icon showing my intel/nvidia status? Any idea? I tried a reboot as well just in case but still nothing.

I just noticed I didn't install pkroot. Is that my problem?

Do you have the Argos extension enabled in the "Gnome Tweak Tool" program? If you do not install pkroot, you will not be able to change the graphics settings. The Optimus-Switch scripts require root access to run. Pkroot allows you to run bash scripts as root from shortcuts.

1 Like

Argos is enabled. I didn't install pkroot as I didn't initially see it.
Do you recommend the full install?

$ git clone https://github.com/cyberalex4life/pkroot.git
$ cd pkroot
$ chmod a+x runwithpkexec pkroot
$ sudo cp org.freedesktop.policykit.pkexec.runwithpkexec.policy /usr/share/polkit-1/actions

## If "/usr/local/bin" does not exist, create it ##
$ ! [ -d "/usr/local/bin" ] && sudo mkdir -p /usr/local/bin || echo 'Folder exists'

$ sudo cp -t /usr/local/bin runwithpkexec pkroot

Also, will I need to run these commands again after installing pkroot?

sudo cp pkroot /usr/local/bin
sudo chmod a+x /usr/local/bin/pkroot

@shockwave Thank you for catching that! I missed adding the pkroot stuff to my repository. :man_facepalming: Dang Gummit. I have updated my repository adding the needed files. I would do this instead.

git clone https://github.com/linesma/Optimus-Switch-Indicator-Argos-Manjaro.git
cd Optimus-Switch-Indicator-Argos-Manjaro
# copy polkit policy in place
sudo cp org.freedesktop.policykit.pkexec.prime-select.policy /usr/share/polkit-1/actions/
# copy pkroot to '/usr/local/bin' and make sure it is executable
sudo cp pkroot /usr/local/bin
sudo chmod a+x /usr/local/bin/pkroot

Sorry about that, and thank you again for catching that.

As for your Argos issue. Navigate to

~/.config/argos/

and make sure that the optimus-switcher.sh file is there. If it is, we may need a permissions change to it. Try this:

sudo chmod +777 ~/.config/argos/optimus-switcher.sh

1 Like