WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Xtc and ~/.X.d/ scripts  (Read 9563 times)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Xtc and ~/.X.d/ scripts
« on: February 17, 2018, 10:03:34 PM »
I have modified ~/.xinitrc in the Xtc package to execute the scripts in ~/.X.d in order of the starting characters being numbers first, then letters.  So if you want a script to run last, it could be named  for example zzzsettime to run last, or aaasoundsetup to run first.  Scripts starting with numbers will run before those starting with letters and will run in numerical order.   This allows control of the executing order of ~/.X.d/ scripts.

~/.xinitrc is probably in your backup and would need to be removed from it to see this change upon update of Xtc.

MODIFIED:  Spelling
« Last Edit: February 17, 2018, 10:06:42 PM by Jason W »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11621
Re: Xtc and ~/.X.d/ scripts
« Reply #1 on: February 17, 2018, 11:39:58 PM »
Hi Jason W
... Scripts starting with numbers will run before those starting with letters and will run in numerical order. ...

Is this a true numerical sort or are you using an alphanumerical sort? I ask because unless numbers are padded with leading
zeros to make them all the same width, an alphanumerical sort will do this:
Code: [Select]
tc@box:~$ cat 123
1a
1A
11a
11A
12
tc@box:~$ cat 123 | sort
11A
11a
12
1A
1a
tc@box:~$

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Xtc and ~/.X.d/ scripts
« Reply #2 on: February 18, 2018, 12:43:20 AM »
Here is the results of the order of files you mentioned -

1/11a
1/11A
1/12
1/1a
1/1A

It is the sort command run on the ~/.X.d/ scripts
« Last Edit: February 18, 2018, 12:56:37 AM by Jason W »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11621
Re: Xtc and ~/.X.d/ scripts
« Reply #3 on: February 18, 2018, 01:16:05 AM »
Hi Jason W
So to prevent things like 11A and 12A from executing before 1A, one should ensure the numeric field is the same width
on all filenames.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Xtc and ~/.X.d/ scripts
« Reply #4 on: February 18, 2018, 10:21:28 AM »
Hi Rich. 

'sort -V' produces the below result which seems more what folks would expect.  I will use it in place of 'sort'.

Code: [Select]
1A
1a
11A
11a
12
AAA
ZZ
aaax
zzzx

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11621
Re: Xtc and ~/.X.d/ scripts
« Reply #5 on: February 18, 2018, 10:53:42 AM »
Hi Jason W
Is the default in dCore  GNU sort  or  busybox sort? If it's  busybox sort,  then the  -g  option looks like it will work for this use too:
Code: [Select]
tc@box:~$ cat 123
12
1a
11a
1A
11A
tc@box:~$ cat 123 | busybox sort -g
1A
1a
11A
11a
12
tc@box:~$

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Xtc and ~/.X.d/ scripts
« Reply #6 on: February 18, 2018, 03:52:58 PM »
Oops, it's busybox.  Actually, 'busybox sort -dn' gives a goog output also. 


Code: [Select]
jason@box:~/1$ /bb/find  | /bb/sort -dn
.
./AAA
./B
./B1
./B12
./B123
./ZZ
./a1
./a10
./a11
./aaax
./zzzx
./1A
./1a
./11A
./11a
./12
jason@box:~/1$


'busybox sort -g' gives me the following:

Code: [Select]
jason@box:~/1$ /bb/find  | /bb/sort -g
.
./11A
./11a
./12
./1A
./1a
./AAA
./B
./B1
./B12
./B123
./ZZ
./a1
./a10
./a11
./aaax
./zzzx
jason@box:~/1$


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11621
Re: Xtc and ~/.X.d/ scripts
« Reply #7 on: February 18, 2018, 04:37:27 PM »
Hi Jason W
I guess my version of  busybox sort -g  just works better than yours. :) At any rate, looks good.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11621
Re: Xtc and ~/.X.d/ scripts
« Reply #8 on: February 18, 2018, 05:06:52 PM »
Hi Jason W
Interesting. Using your list I get the same result:
Code: [Select]
tc@box:~$ cat 123 | sort -g
./11A
./11a
./12
./1A
./1a
./AAA
./B
./B1
./B12
./B123
./ZZ
./a1
./a10
./a11
tc@box:~$
However, if I remove the leading  ./  from the entries, I get the correct result:
Code: [Select]
tc@box:~$ cat 123 | sort -g
AAA
B
B1
B12
B123
ZZ
a1
a10
a11
1A
1a
11A
11a
12
tc@box:~$

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Xtc and ~/.X.d/ scripts
« Reply #9 on: February 18, 2018, 06:25:33 PM »
Hi Rich.  You are right, when I use busybox find and "sort -g" I get the right order if I use the command as it basically  is in .xinitrc and I think that should work.


Code: [Select]
jason$ /bb/find /home/jason/.X.d/ -type f -print | /bb/sort -g
/home/jason/.X.d/1
/home/jason/.X.d/10
/home/jason/.X.d/100
/home/jason/.X.d/1000
/home/jason/.X.d/10A
/home/jason/.X.d/10B
/home/jason/.X.d/10a
/home/jason/.X.d/10b
/home/jason/.X.d/12
/home/jason/.X.d/123
/home/jason/.X.d/321
/home/jason/.X.d/4
/home/jason/.X.d/5
/home/jason/.X.d/55
/home/jason/.X.d/AA
/home/jason/.X.d/ZZ
/home/jason/.X.d/aa
/home/jason/.X.d/aaaastartupsound
/home/jason/.X.d/df
/home/jason/.X.d/mouse
/home/jason/.X.d/pulseaudio
/home/jason/.X.d/time
/home/jason/.X.d/wbar
/home/jason/.X.d/xrandr
/home/jason/.X.d/xterm
/home/jason/.X.d/zz
/home/jason/.X.d/zzrollup
jason$

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: Xtc and ~/.X.d/ scripts
« Reply #10 on: February 24, 2018, 02:34:29 PM »
Hi
I propose to not execute scripts in ~/.X.d/ which terminates with ~
dCore user

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Xtc and ~/.X.d/ scripts
« Reply #11 on: February 24, 2018, 02:58:13 PM »
Ok, sounds useful.  I think also not executing those that end in .bak, that is what I name my backup files. 

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Xtc and ~/.X.d/ scripts
« Reply #12 on: February 24, 2018, 08:51:05 PM »
Done and uploaded, please test.