Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda