You are not logged in.

#1 2015-12-23 04:20:43

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Adding Executable Commands to "Passive" Scripts

Hey guys. So I'm wondering about the ability to add executable commands or executable scripts to things like .conf files. For example, I'd like to edit my lightdm.conf file to play a small .wav file when the lightdm process is run or when I successfully log in. Or perhaps the /etc/motd conf file, when the motd is read, it could reference an executable shell script.   Now I know for security purposes this is definitely a big No No. I run this all in a VM and have little on the system that I consider information that needs protecting. So security issues aside... Is there a what to add commands to scripts like .confs that are generally just read for parameters.


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#2 2015-12-23 07:50:18

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,652
Website

Re: Adding Executable Commands to "Passive" Scripts

Moved to  Basic Help & Support. ( "Scripts Tutorials & Tips" is for sharing, not asking. )


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

#3 2015-12-23 16:58:11

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,057

Re: Adding Executable Commands to "Passive" Scripts

For lightdm, be sure to check out these options in lightdm.conf

#display-setup-script=
#display-stopped-script=
#greeter-setup-script=
session-setup-script=/usr/lib/bunsen/bunsen-configs/bl-user-setup

As you can see BL is using session-setup-script to copy its configs up into a $HOME directory when a new user is setup. If you needed that particular option, then it should be possible to build a wrapper script that included your own custom script PLUS the bl-user-setup script. Also consider the fact that ~/.config/openbox/autostart is actually a shell script. Simlarly with /etc/xdg/autostart, though in that case you would likely need to build desktop entries to execute your scripts in. Also, keep in mind that anything you can run from the command line can be considered an extension of your shell in a way. (This is truly one of the things that makes Linux so cool.) Meaning if you wanted to modify /etc/motd and display it, you could create a script that does it.

Offline

#4 2015-12-23 19:47:09

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Adding Executable Commands to "Passive" Scripts

For an Openbox session login startup sound then just add the command to autostart


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#5 2015-12-24 02:18:57

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,652
Website

Re: Adding Executable Commands to "Passive" Scripts

tknomanzr wrote:

~/.config/openbox/autostart is actually a shell script.

To be pedantic, it's a code fragment which is sourced by another shell script. That's why it doesn't need a #!/bin/sh at the top. Also, it's being run by sh not bash so you can't use bash-specific code.

anything you can run from the command line can be considered an extension of your shell in a way. (This is truly one of the things that makes Linux so cool.)

Yes!

EDIT: removed incorrect statement.

Last edited by johnraff (2015-12-25 06:46:34)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

#6 2015-12-24 04:55:56

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,057

Re: Adding Executable Commands to "Passive" Scripts

^ Good to know. Thanks for the clarification, especially about it running sh instead of bash. That could have ended up frustrating some day tongue

Offline

#7 2015-12-24 17:50:22

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Adding Executable Commands to "Passive" Scripts

Thanks to all who responded! Yea editing the autostart script I suppose is the most obvious choice then for specifically doing what I need. and Twoion's explanation is a great more deeper level reasoning.

So I suppose my next question in my never ending list, is why do we need a Window Manager for an autostart script?  What i mean is, the .config/openbox/autostart  script isn't run if openbox isn't installed. Why is there no 'autostart' like script if you're not running X or a windows manager?  I mean there is the .bashrc and or .profile  scripts. But I don't think you can add actual commands to them as you can in the autostart script.
So why does having the functions of autostart only seem to come with using a WindowManager like xdg or openbox?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#8 2015-12-24 17:54:11

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: Adding Executable Commands to "Passive" Scripts

Horizon_Brave wrote:

Why is there no 'autostart' like script if you're not running X or a windows manager?

Read startx(1)

In Debian jessie, ~/.xsession is used.

EDIT: Openbox uses the autostart file as a convenience for people running a so-called default xsession without a file at ~/.xsession

Last edited by Head_on_a_Stick (2015-12-24 17:55:12)

Offline

#9 2015-12-24 18:59:08

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Adding Executable Commands to "Passive" Scripts

ps:
autostart only gets executed if you use "openbox-session".
i have "exec openbox" at the end of my ~/.xinitrc, and have to put everything i want autostarted into ~/.xinitrc.
i like it that way (openbox-session also does a few more "useless" things, like executing xdg/autostart stuff and setting the background to a uniform grey).

Offline

#10 2015-12-25 01:45:04

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Adding Executable Commands to "Passive" Scripts

heh, from the startx man page...and from Johnraff's post here:

#! startx Explanation

the startx utility seems pretty useless, as either xsession is called by the xinitrc or if you specify another script like autostart...


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#11 2015-12-25 01:56:35

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: Adding Executable Commands to "Passive" Scripts

Horizon_Brave wrote:

the startx utility seems pretty useless, as either xsession is called by the xinitrc

In Debian jessie systems, the `startx` command will either start whichever window manager or desktop environment is symlinked to /etc/alternatives/x-session-manager or it will run whichever programs are specified in ~/.xsession (or ~/.xinitrc if this is sourced from ~/.xsession) if such a file is present.

If a display manager is not used then either the `startx` or `xinit` commands must be used to initialise the X server.

Note that if the `xinit` command is used, further arguments must be passed, for example:

xinit -- :1 -nolisten tcp vt$XDG_VTNR

Offline

#12 2015-12-25 06:03:39

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,652
Website

Re: Adding Executable Commands to "Passive" Scripts

startx does a lot more than just start the x server and a window manager. It adds any environment variables, services, daemons etc from script fragments that installed packages might have put in /etc/X11/Xsession.d ( dbus, ssh, ... even BunsenLabs puts something there! ) That stuff is also run when starting via LightDm.

Try this for an idea of it:

for i in /etc/X11/Xsession.d/*;do echo "$i":;cat "$i";echo ------;done | less

PS Horizon_Brave has already found my dissertation on startx from 3 years ago. A longish read.

Last edited by johnraff (2015-12-25 06:07:57)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

#13 2015-12-25 06:51:00

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,652
Website

Re: Adding Executable Commands to "Passive" Scripts

About openbox/autostart, I was wrong:

johnraff wrote:

it's a code fragment which is sourced by another shell script.

It may have been true in the past, but now it's run by 'sh /path/to/autostart'. See /usr/lib/[i386|amd64]-linux-gnu/openbox-autostart


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

Board footer

Powered by FluxBB