Always launch a program with additional parameters Ubuntu 20.04

Click For Summary
SUMMARY

To launch Chromium with a specific proxy on Ubuntu 20.04, users can create an alias in the terminal, such as alias chrome='chromium-browser --proxy-server=http://proxy.myproxy:XXXX'. However, launching Chromium via the desktop shortcut requires editing the chromium.desktop file to include the proxy settings in the Exec line. Users have reported difficulties with the Snap version of Chromium, which does not create a desktop launcher. A successful workaround involves creating a bash script that executes the Chromium command with the desired proxy settings.

PREREQUISITES
  • Familiarity with command line operations in Ubuntu 20.04
  • Understanding of creating and editing bash scripts
  • Knowledge of desktop entry files in Linux
  • Basic understanding of proxy server configurations
NEXT STEPS
  • Learn how to create and edit desktop entry files in Linux
  • Explore bash scripting for automating application launches
  • Research the differences between Snap and traditional package installations on Ubuntu
  • Investigate system-wide proxy settings in Ubuntu 20.04
USEFUL FOR

Linux users, particularly those using Ubuntu 20.04, developers needing to configure proxy settings for applications, and system administrators managing network configurations.

dRic2
Gold Member
Messages
887
Reaction score
225
Hi,

Due to a proxy issue I have to launch chromium with this additional requirement to set the right proxy

chromium-browser --proxy-server=http://proxy.myproxy:XXXX

To get things more easy I defined an alias

alias chrome='chromium-browser --proxy-server=http://proxy.myproxy:XXXX'

so now I just type chrome in the command line and it works. However, I would like to launch the application by right-clicking on it instead of typing chrome in the console. Unfortunately, I am not able to set this proxy thing to work if I open chromium by right-clicking on it. I tried to google it but all the main suggestions failed to work for me (for example I was very optimistic with this one https://askubuntu.com/questions/537...n-application-with-specific-parameters-from-u but it didn't work).
 
Last edited by a moderator:
Technology news on Phys.org
Can't you set the proxy in the OS itself? In that way, all applications accessing the internet will use the proxy.
 
The proxy is already set as an environmental variable, but chromium doesn't read it for some reason. It works for every other application though.
 
dRic2 said:
The proxy is already set as an environmental variable, but chromium doesn't read it for some reason. It works for every other application though.
That shouldn't happen.

I am not sure how to set proxy using environment variable, but in the past, I have followed the steps below, and it worked fine for Chrome.

Step 1: Go to Settings.

Step 2: Go to Network on the LHS panel:

1637785577308.png


Step 3: Click on the gear button next to Network Proxy:

1637785645844.png


Step 4: Choose "Manual" and set up the proxy:

1637786083201.png


Step 5: You can just close the windows after setting up. Changes should take place immediately.
 
This is something that Gnome makes unnecessarily difficult (I assume you are on Ubuntu 20.04 or similar): you could consider switching to another flavour of Ubuntu or even a different distro (that doesn't use Canonical's evil snap distributions).

But if you are sticking with Gnome, you can try the instructions here: https://linuxconfig.org/how-to-create-desktop-shortcut-launcher-on-ubuntu-20-04-focal-fossa-linux to create a launcher on your desktop with the right option (I don't know if you can easily change the option in the Gnome menu).

You will have to edit the Exec action to add the proxy option.

Edit: oh, the snap distribution of Chromium doesn't create a desktop launcher, I told you it was evil.
 
Last edited:
@pbuk Shouldn't it be enough to change the proxy on the system level? I generally change launcher entries if they are something specific for that application. If it is something that should be used by all applications throughout the system, shouldn't we first change the system setting, if it is available?
 
@Wrichik Basu if you type in the terminal echo $http_proxy (or $HTTP_PROXY) and it outputs the proxy that you set then your method should be equivalent to mine.

@pbuk yeah... I tried to edit the Exec but it failed 😭
 
  • Informative
Likes   Reactions: Wrichik Basu
dRic2 said:
@pbuk yeah... I tried to edit the Exec but it failed 😭
If you have managed to find the one in the Gnome launcher you probably need elevated privileges to edit it.
 
I use Linux Mint: no Gnome to fight, no nasty snap installations.
 
  • #10
Wrichik Basu said:
it worked fine for Chrome.
Yeah, Google make sure Chrome works. Canonical have wrapped the open source Chromium in their proprietory Snap package manager so, it seems, it doesn't. Take it up with Canonical (who own Ubuntu), or walk to a more free distro.
 
  • Informative
Likes   Reactions: Wrichik Basu
  • #11
pbuk said:
If you have managed to find the one in the Gnome launcher you probably need elevated privileges to edit it.
No I mean, I successfully edited the Exec lines in the chromium.desktop file, but it didn't change anything.
 
  • #12
dRic2 said:
No I mean, I successfully edited the Exec lines in the chromium.desktop file, but it didn't change anything.
Even when you ran chromium by double-clicking the desktop icon?
 
  • #13
pbuk said:
Even when you ran chromium by double-clicking the desktop icon?
yep. I will try again tomorrow... I didn't get the chance today.
 
  • #14
I solved the problem by creating a bash script and placing it on the desktop so that I can simply click on it as it was a shortcut. Everything else failed. Thanks though! :D

[CODE lang="bash" title="launch_cromium.sh"]#!/bin/bash

chromium-bowser --proxy-server="MYPROXY:MYPORT" &
exit[/CODE]
 
  • Like
Likes   Reactions: jim mcnamara and Wrichik Basu

Similar threads

  • · Replies 1 ·
Replies
1
Views
5K
Replies
6
Views
9K
Replies
7
Views
3K
Replies
21
Views
5K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 15 ·
Replies
15
Views
6K
Replies
10
Views
2K
Replies
2
Views
3K
  • · Replies 21 ·
Replies
21
Views
6K
Replies
16
Views
3K