Solved syntax to set environment variable

In freebsd 13.1 with kde plasma5, a print command (no printer attached, the command is to print to a pdf) brings up the print to a pdf window without delay, but it takes a bit of time to load the preview and process print command. I found this kde thread that indicates that says

If you don't have any network print queues and you find the delay too annoying, it can be disabled by setting the QT_DISABLE_PRINTER_DISCOVERY environment variable to 1 in /etc/environment .

I found /usr/home/username/.profile, is it ok to say
QT_DISABLE_PRINTER_DISCOVERY=1

Or, is the syntax different? Also, do I have to modify the /.profile accordingly?
 
Yes, you need to export(1) that variable, or else 'child' processes won't inherit it. https://www.grymoire.com/Unix/Bourne.html


It depends on the shell you are using. ~/.profile is specific to Bourne shells (sh, bash, etc).

As this is a specific setting for a GUI application it might be better to set this variable in ~/.xinitrc.

Thank you SirDice export(1) and https://www.grymoire.com/Unix/Bourne.html seem complex for me to learn. I will live with a bit of delay on print commands. :(
 
Thank you @SirDice export(1) and https://www.grymoire.com/Unix/Bourne.html seem complex for me to learn.
Really quick and simple example:

With a shell you can set variables [*]:
Code:
$ echo $BAR

$ BAR="Something"
$ echo $BAR
Something
This is simple to understand right? The 'problem' however is that a child process (another shell for example) won't inherit variables from the parent:
Code:
$
$ echo $BAR

$ BAR="Something"
$ echo $BAR
Something
$ sh # starting a 'child' process
$ echo $BAR

$
As you can see the second shell doesn't know what BAR is, this is where export(1) comes in:
Code:
$ echo $BAR

$ BAR="Something"
$ echo $BAR
Something
$ export BAR
$ sh
$ echo $BAR
Something
$
Because the BAR variable was 'exported' the child process (shell) does know it now. Does that make sense to you?



[*] Using a Bourne Shell specifically here, other shells like the C Shells have variables too but they're handled differently.
 
That is very helpful SirDice . It is a 101 lesson, and utterly easy to understand. Thank you for explaining it so lucidly.

Yet, what would be the syntax from the linux help page QT_DISABLE_PRINTER_DISCOVERY=1 differs from the way the environment variables are defined in freeBSD. At my level, it reaches me as:

$ echo QT_PRINTER_DISCOVERY
$ PRINTER_DISCOVERY =1
export PRINTER_DISCOVERY

Could this be correct?

Thank you.
 
How are you starting KDE? With SDDM or through startx? You might be able to set it in ~/.xinitrc. But I'm not sure that file is even used with the SDDM/KDE combination. You could set it system-wide and set it in /etc/profile:
Code:
export QT_DISABLE_PRINTER_DISCOVERY=1
 
How are you starting KDE? With SDDM or through startx? You might be able to set it in ~/.xinitrc. But I'm not sure that file is even used with the SDDM/KDE combination. You could set it system-wide and set it in /etc/profile:
Code:
export QT_DISABLE_PRINTER_DISCOVERY=1

To make plasma work I had to add exec ck-launch-session startplasma-x11 in ~/.xinitrc Now I added
export QT_DISABLE_PRINTER_DISCOVERY=1 and also set it system-wide in /etc/profile. This is how /etc/profile looks now:

# Check system messages
# msgs -q
# Allow terminal messages
# mesg y
export QT_DISABLE_PRINTER_DISCOVERY=1

Thank you SirDice. I think it should be alright now :)
 
To make plasma work I had to add exec ck-launch-session startplasma-x11 in ~/.xinitrc Now I added
export QT_DISABLE_PRINTER_DISCOVERY=1
Ok, that's good. Just make sure to put the export and the variable before the exec(1) line. The exec(1) causes the execution to never return, thus anything put after it won't get executed.
 
Back
Top