Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Alter Behavior of xdg-open

I use the command xdg-open quite a lot in my Ubuntu Linux terminal. However, two things irk me:

  1. Is it possible to suppress the error messages?

  2. Is it possible to get the command to always complete? (That is, not continue running, so that I have another "new line" in my terminal).

I realize 2 may not be possible, because of the way the program works, but I imagine 1 is.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

First one is easy. Just

alias xdg-open="xdg-open 2>/dev/null"

If you want it permanently, just add that line to ~/.bashrc file.

I recommend you to think twice if you want to become blind to errors, though.

The second one is quite confusing to me. xdg-open shouldn't be intereactive. In my computer (Debian sid) xdg-open execs the command and ends, even if the command itself has not ended (ie: you have not closed the application opened for the URL). I think this should be the behaviour of xdg-open on any platform (it's supposed to work exactly the same way on any XDG system, that's its very purpose).

Anyway, for any command you launch in a shell, if you want it to be non-interactive, that is, to allow to enter commands even if the previous one hasn't finished, you just attach "&" to the end of it. Example:

# prompt is not shown until you close the calculator
$ gnome-calculator
# prompt is shown right after opening calculator and you can 
# work on the shell even if you don't close it
$ gnome-calculator &
over 4 years ago · Santiago Trujillo Report

0

I maybe late for the answer, but I got exactly the same problem like you have / had.

I tried to start a URL with xdg-open, my default browser is firefox, and not xdg-open but firefox started with an error:

[user@user-pc ~]$ xdg-open https://www.google.de # the page opens fine, but firefox had an error
[user@user-pc ~]$ 
(process:3783): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

# needed to press enter here

xdg-open closed fine but the firefox error stayed and I need to press enter to get the bash moving.


To get along this problem I called xdg-open within a new shell putting those output to /dev/null:

bash -c "xdg-open https://www.google.de" 2> /dev/null

The page opened fine, no error shown – rather nothing has been shown. And no need to press enter.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!