You are not logged in.

#1 2019-05-18 13:48:46

Baitinq
Member
Registered: 2019-05-18
Posts: 11

Bash Condition

Hello,


I have been trying to move from using sddm as a display manager to using simply startx. During the process of moving from sddm to startx i had to configure certain things that sddm did automatically but (obiously) my xinitrc script did not. I have added most of the functionality that sddm provided by default but there is one thign that I cant seem to solve or find and answer to.

In my i3 config I have binded a program (roficlip: https://github.com/gilbertw1/roficlip/) which displays my clipboard (obtained through clipster) into a rofi window. It all worked correctly when I used sddm but when I switched to the startx method the program simply doesnt launch. I have taken a look to the source (https://github.com/gilbertw1/roficlip/b … r/roficlip) and I see there is a variable (if [[ -t 0 ]]; then) that dictates weather the output of roficlip will be displayed on rofi or thorugh a terminal. And that variable changes from false to true when I am not using sddm. I have reasearched a bit and it looks like  the variable checks if you are in a terminal or not. I was wondering what could be the cause of that bash variable (-t) detecting I am on a terminal when i am using xinit (and im in graphical mode with i3) and it doesnt and works normally when the i3 session is launched through sddm.

Many thanks for the help.

Last edited by Baitinq (2019-05-18 13:48:55)

Offline

#2 2019-05-18 13:57:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Bash Condition

SDDM presumably closes the standard streams (which is really a horrible idea in my view).  Startx leaves the streams open, so - for example - anything i3 or any program started via a i3 key binding prints to stdout goes to the underlying tty.

But this also means when these programs check if the stdin is a terminal, they will get a 'true' result.  If you want to change that, you can change the binding that launches the program to redirect the stdin from /dev/null, e.g.

roficlip -args -args < /dev/null

Alternatively, you could redirect the stdin before launching i3 to get a global behavior similar to SDDM:

exec 0</dev/null
exec i3

(don't mind the similar look of the two "execs", they mean completely differnt things unfortunately).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2019-05-18 14:30:14

Baitinq
Member
Registered: 2019-05-18
Posts: 11

Re: Bash Condition

Thanks a lot, it worked.

Offline

#4 2019-05-18 17:50:25

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Bash Condition

Please remember to mark your thread [SOLVED] (edit the title of your first post).
How to Post

Offline

Board footer

Powered by FluxBB