[Solved] How can I run terminal commands at login?

,

For the last few months I’ve been running the same two commands every day without fail and I’ve finally concluded I should automate this, I remember in Mint I could add commands to the bottom of the .profile file (which I had to for screen resolution issues), is there an equivalent in Fedora?

The commands I need to run are these:

pactl load-module module-null-sink sink_name="OBSAudio"
pactl load-module module-loopback sink="alsa_output.usb-ASUS_Xonar_U7_MKII-00.analog-stereo" source="OBSAudio.monitor"

EDIT Solution: Made a script using this guide provided by George below and put it in the Autostart second of KDE’s settings menu per Yosuke’s suggestion.

$HOME/.profile is widely used across many linux distros when bash is the login shell, so the short answer is that many $HOME/.profile entries work on many distros. For such questions, you should first refer to generic linux resources such as Linux Command. They are widely used so have the benefit of being very well tested across distros and around the world (and predate the AI clickbait sites that dominate today’s internet).

It is generally better to add the settings you are using to the pulseaudio configuration file: see Pulseaudio – configure default profile.

A quick idea is to have those in a .sh script somewhere, then make a XDG autostart .desktop file that calls it.

I feel PA would have a better way to do those settings in a config file though.

I had a look over the Pulseaudio configuration article and perhaps on account of having Pipewire based audio(?) I don’t have a /etc/pulse/default.pa, I could create it but I’m not confident playing with that sort of thing.

So I’m now reading over the Linux Command stuff and I think I’m getting the gist of it, if I’m understanding this correctly I can add commands to the bottom of /.bash_profile or /.bashrc?

Edit: Sorry for being a bit awkward and/or uncooperative, I’m a bit beyond my depth here.

The bash documentation says:

When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

So if there’s an existing ~/.bash_profile (I think on Fedora there is, by default), then that’s the “first one that exists”, and so ~/.profile isn’t used.

I see you’ve tagged this with kde. There is an Autostart section in Settings where you can put your own scripts; these will run upon login:

Thank you all for your help, I’m not entirely sure I’ve proverbially learned to fish but I have succeeded in making a script file that runs on log in and creates my sinks and loopbacks.

if you can share how you managed to solve your issue, it would help others in the future as well

1 Like

Edited opening post with said solution, thanks for the etiquette reminder.

Well, instead of editing the original post, it would be better to write the solution in a reply, but ok.