Saturday, December 14, 2019

How to use the nvidia gpu on-demand on ubuntu 19.10 for optimus laptops (a short reminder for myself)

I am currently on Ubuntu 19.10. I used 'prime-select' to select the 'on-demand' option thus:

$ sudo prime-select on-demand

Then rebooted. Now, all programs seem to use the default Intel graphics. To use steam and other programs with nvidia, I run then thus:

$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia steam

And then from steam, I can see from my system information that the nvidia gpu is indeed being shown, which is not true (and shows the intel card) without the above options.


Monday, August 4, 2014

Using xdg-mime to set default programs to open certain filetypes in Linux

Recently I had a need to set xpdf as the default program for opening pdf files instead of evince. I decided to use the command line to achieve this. Turns out that I can do this using xdg-mime.

To know what is the filetype (in the mime 'language') of pdf files:

 $ xdg-mime query filetype Programming.pdf  
 application/pdf  

Once I know the mime type of pdf files, I can see the default program currently used to open pdf files:

 $ xdg-mime query default application/pdf  
 evince.desktop  

So, now I know that evince is being used as the default pdf file opener, and that there is a desktop file by the name of evince.desktop. The location of this file can easily be found using programs like 'locate':

 $ locate /evince.desktop   
 /usr/share/applications/evince.desktop  

Now I know where such desktop files are kept on my system. After installing xpdf, xpdf.desktop also turned up there (if not it is easy to create such a desktop file). So now I can make xpdf as the default program for opening pdf files using the following:

 $ xdg-mime default xpdf.desktop application/pdf   

That's it. Now if I try to click on a pdf file, xpdf is used to open it.


Thursday, July 31, 2014

Making git know about my http and https proxy server

Following is the general syntax of the commands that will set the http and https proxy servers for git:

 git config --global http.proxy http://proxyuser:proxypassword@proxyserver:proxyport  
 git config --global https.proxy http://proxyuser:proxypassword@proxyserver:proxyport  

For example, if I want to set the http and https proxy servers to 192.168.10.10:3128, then I would use the following command (assuming my proxy server requires no authentication):

 git config --global http.proxy http://192.168.10.10:3128
 git config --global https.proxy http://192.168.10.10:3128


Sunday, June 15, 2014

Go away Desktop icons... again!

I want my desktop to be clean. That means no icons. Recently I have been trying various window managers, and finally I settled down to i3 for the past few weeks. I love it.

Today, I just wanted to log into Unity just for change, and found things have changed since I last logged into it. That's strange since I never did this and nobody is using my PC. I was seeing desktop icons!

I wanted to get rid of those. So I used gsettings to find out 'who' was responsible for this. It turned out to be some program called nemo. The following command:

 ➜ ~ gsettings list-recursively | grep -i desktop | less  

turned up, among other things, this:

 org.nemo.preferences desktop-is-home-dir true  

So, to set things right, I had to do this:

 ➜ ~ gsettings set org.nemo.desktop show-desktop-icons false  

Now, things are right again.

Now that I think about this, I did play with Cinnamon recently, didn't quite like it, and then forgot all about it. Maybe, this was a result of that adventure... nemo being a part of Cinnamon...

(Oh, in case anyone was wondering, those command prompts are due to oh-my-zsh that I am using nowadays)

Wednesday, June 4, 2014

Getting audio volume go beyond 100% in Ubuntu Gnome

In some videos I find the audio volume to be too low, even after the I turn the volume up to 100%. However, from gnome's sound control, I can see that I can use the mouse to make the volume go beyond 100% so that the audio becomes louder.

So, I was looking for a command line that would do that for me, so that I can assign that to a keyboard shortcut so that every time I needed louder sound, I would not have to use my mouse to reach out for the gnome sound control.

I turned out that the pactl command (from pulseaudio-utils package in Ubuntu) can be used for this purpose.

To make the volume go up by 10%, the command would be:

 pactl set-sink-volume 0 +10%  

And to make the volume go down by the same amount, the command would be:

 pactl set-sink-volume 0 -- -10%  

(The '--' in the command above is necessary otherwise it is interpreted as a command line option and I get an error. The '--' basically stops the shell from option parsing from that point onward)

This command allows me go beyond 100%

Now I have assigned this command to a shortcut key in Gnome and my problem is solved :-)

BTW, if there are more audio devices, the index may need to be changed from 0 (I have only one, so the index is 0 in my case). More details are available in the 'pactl' and 'pacmd' manual pages.