WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline andyj

  • Hero Member
  • *****
  • Posts: 1020
System script directory for .xsession
« on: October 31, 2018, 06: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.



Offline curaga

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

Offline Juanito

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

Offline andyj

  • Hero Member
  • *****
  • Posts: 1020
Re: System script directory for .xsession
« Reply #3 on: November 01, 2018, 08: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: 14516
Re: System script directory for .xsession
« Reply #4 on: November 02, 2018, 12:40:38 AM »
In the meantime, it might not hurt to mention it in the info file?

Offline Juanito

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

Offline andyj

  • Hero Member
  • *****
  • Posts: 1020
Re: System script directory for .xsession
« Reply #6 on: November 11, 2018, 06: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: 14516
Re: System script directory for .xsession
« Reply #7 on: November 11, 2018, 09:04:28 PM »
Does it work with full fat find?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1020
Re: System script directory for .xsession
« Reply #8 on: November 12, 2018, 03: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, 08:12:55 PM »
non-obvious things breaking things still sucks though.
Download a copy and keep it handy: Core book ;)