WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: System script directory for .xsession  (Read 5370 times)

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
System script directory for .xsession
« on: October 31, 2018, 09:05:17 AM »
At the end of .xsesion is a line to execute personal code when X starts:

Code: [Select]
[ -d "$HOME/.X.d" ] && find "$HOME/.X.d" -type f -print | while read F; do . "$F"; done
However, there is no equivalent system-wide line that would be used by everyone so that each account's home directory wouldn't have to be touched. Something like this before the personal code line would be a nice addition to the .xsession skeleton:

Code: [Select]
[ -d "/usr/local/etc/X.d" ] && find "/usr/local/etc/X.d" -type f -o -type l -print | while read F; do . "$F"; done
The specific use case I'm thinking of is open-vm-tools-desktop, but I can imagine more in kiosks, RDP auto connection, and the like.



Online curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11048
Re: System script directory for .xsession
« Reply #1 on: November 01, 2018, 04:26:00 AM »
Agreed
The only barriers that can stop you are the ones you create yourself.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14826
Re: System script directory for .xsession
« Reply #2 on: November 01, 2018, 04:38:26 AM »
Could you submit it as a patch please?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: System script directory for .xsession
« Reply #3 on: November 01, 2018, 11:00:42 PM »
I hope that at least for open-vm-tools-desktop this will eventually help reduce some confusion. In theory TC should probably autostart services in extensions loaded at boot time, but some of them might depend on settings in /opt/bootsync.sh or /opt/bootlocal.sh. I have this at the end of /opt/bootlocal.sh:

Code: [Select]
for a in $(find -L /usr/local/etc/init.d -type f); do
        [ -x $a ] && $a start &
done

I am not sure how to pull this off in a consistent way without having yet another file, given the default behavior that /opt/bootsync.sh quits once /opt/bootlocal.sh starts.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14826
Re: System script directory for .xsession
« Reply #4 on: November 02, 2018, 03:40:38 AM »
In the meantime, it might not hurt to mention it in the info file?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14826
Re: System script directory for .xsession
« Reply #5 on: November 10, 2018, 05:41:25 AM »
.xsession adjusted in Xlibs in tc-9.x x86 and x86_64 repos

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: System script directory for .xsession
« Reply #6 on: November 11, 2018, 09:22:18 PM »
On 9.x I see this in both 32 and 64-bit find with the -print option:

Code: [Select]
tc@box:~$ [ -d "/usr/local/etc/X.d" ] && find "/usr/local/etc/X.d" -type f -o -type l -print
tc@box:~$

The default is to print, so without it I get the expected result:

Code: [Select]
tc@box:~$ [ -d "/usr/local/etc/X.d" ] && find "/usr/local/etc/X.d" -type f -o -type l
/usr/local/etc/X.d/open-vm-tools
tc@box:~$

Why does the -print option break find?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14826
Re: System script directory for .xsession
« Reply #7 on: November 12, 2018, 12:04:28 AM »
Does it work with full fat find?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: System script directory for .xsession
« Reply #8 on: November 12, 2018, 06:23:25 PM »
GNU find works the same. Apparently it is because of the -o or switch. So we need to either use parentheses:

Code: [Select]
tc@box:~$ [ -d "/usr/local/etc/X.d" ] && find "/usr/local/etc/X.d" \( -type f -o -type l \) -print | while read F; do echo "$F"; done
/usr/local/etc/X.d/open-vm-tools
tc@box:~$

Or accept -print as the default behavior and not use it at all:

Code: [Select]
tc@box:~$ [ -d "/usr/local/etc/X.d" ] && find "/usr/local/etc/X.d" -type f -o -type l | while read F; do echo "$F"; done
/usr/local/etc/X.d/open-vm-tools
tc@box:~$

I vote for the second more terse option.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: System script directory for .xsession
« Reply #9 on: November 12, 2018, 11:12:55 PM »
non-obvious things breaking things still sucks though.
Download a copy and keep it handy: Core book ;)