Picking up all the default execs in /etc/profile.local

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Picking up all the default execs in /etc/profile.local

#1 Post by musher0 »

Hello all.

I've been hacking /etc/profile tonight.

Barry's original does the job, but it's repetitive (lines 66-75) and does
NOT absorb as vars all the "default*" scripts modern Puppies have at
/usr/local/bin.

I tried using referenced variables (something like "${!DEFAULTTHINGY}")
with names derived from the file names and got nowhere.

So I used sort of a create-the-variable-on-the-rebound kind of script.
Read the comments in the script and you'll see what I mean.

We create a separate file from the listing of /usr/local/bin/default*,
process it and then incorporate it at the top of profile.local -- which we
have to create if we don't have it already. No big deal, though.

This is the top of my new /etc/profile.local now:

Code: Select all

# /etc/profile.local
 . /tmp/default-execs.tbl
(...)
You can put whatever else you need below that line: add-ons to the
PATH, various LANG variables, etc.

Then we can remove lines 66-79 in /etc/profile.

CAUTION: FOR EXPERIENCED USERS ONLY. DO NOT USE THIS SCRIPT
IF YOU DO NOT KNOW WHAT YOU ARE DOING.

Code: Select all

#!/bin/bash
# /root/my-applications/bin/essai2.sh
# (Renommer comme vous voulez / Rename as you like.)
#
# Pour remplacer les énoncés "DEFAULT" dans /etc/profile /
# To replace the "DEFAULT "statements in /etc/profile
#
# Please read the embedded comments.
#
# (c) musher0, 16 Dec. 2018. GPL3.
####
cd /usr/local/bin
ls --file-type default* | grep -vE "changer|handler|imageeditor" > /tmp/default-execs # | wc -l # 29 au total
# There are 29 practical "default*" execs in XenialPup-706's /usr/local/bin
# the user can readily use. YMMV depending on your Pup.
# That's more than BarryK's original set.
# We leave imageditor out because it's a symlink for defaultpaint;
# changer, you may leave in, but handler should stay out to avoid accidents.

> /var/default-execs.tbl # formerly /tmp/default-execs.tbl
while read line;do
     echo "export ${line^^}=/usr/local/bin/$line" >> /var/default-execs.tbl
done < /tmp/default-execs
rm -f /tmp/default-execs
cd -
# Then we create profile.local if non-existent and/or incorporate
# . /var/default-execs.tbl
# at the top.
#
# If we have a memory lapse we can run
# more /var/default-execs.tbl
# to refresh our memory.
One advantage I can see of having all the default scripts as variables is
that, if you can't remember, e.g., which screenshot utility you have on
this Pup, you open a console, you type

Code: Select all

$DEFAULTSCREENSHOT
and away you go.

~~~~~~~~~

Edit, the following day:
/tmp/default-execs.tbl replaced by /var/default-execs.tbl in the above,
since we are dealing here with long-term variables.

I also incorporated a short form of the above edited script in /etc/profile.
(Please see attached zip file.) This way, should /var/default-execs.tbl
be erased (stuff in /var is not intended to be stored there for ever and
ever; longer than in /tmp, but not forever), /etc/profile can recreate
it and /profile.local, pick up the fresh copy.
End of edit.


~~~~~~~~~

You could as well type < defaultscreenshot > directly, I suppose. :(
FWIW. I hope this can be useful if only as an exercise.

~~~~~~~~~

Edit, the following day:
Why did BarryK do it like that, anyway? He is using these
$DEFAULTEXECS in some of his other scripts, I suppose?
End of edit.


~~~~~~~~~

Any constructive comments welcome.

BFN.
Attachments
etc-edited-profile.zip
(1.76 KiB) Downloaded 195 times
Last edited by musher0 on Tue 18 Dec 2018, 03:07, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

ITSMERSH

#2 Post by ITSMERSH »

Ein Bild sagt mehr als 1000 Worte! :wink:
Attachments
Screenshot.jpg
(160.1 KiB) Downloaded 213 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Euh...

Indeed, a picture is worth 1,000 words.
That proverb exists in many countries.

But is that a "thank you" ? Was my remark useful, or you already knew?

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

ITSMERSH

#4 Post by ITSMERSH »

Hi musher0.
You could as well type < defaultscreenshot > directly, I suppose.
It was more or less meant as a statement to the above quote.

Having a global environment variable exactly named after the defaultXXX script isn't really very useful. So, I just thought I would give a different example for a useful definition and use of global environment variables.

E.g.:

Code: Select all

root# echo $MYICONPLACEORIENTATION
bottom
root# 
root# echo $MYICONPLACESTARTGAP
24
root# 
root# echo $MYICONPLACEEDGEGAP
72
root# 
root# echo $MYICONPLACESPACING
68
root# echo $MYICONTHEME
LP2Studio
root#
These values are submitted at boot (booting RAM only in general) by a config file (T.O.P.L.E.S.S., N.E.M.E.S.I.S.) and being used to change the drive icons orientation data before X desktop is active.

If I'm changing it during my session, I can reset it immediately by these global environment variables.

Those variables (image in my previous post) starting with $MYARUN... are used to switch autostart of those programs (.desktop files) in /root/.config/autostart before booting.

I have lots of programs made into a RoxApp. These RoxApps are stored on external drives/partitions. But I can run them from a menu entry, just like those programs being installed or built in.

It doesn't matter if booting from internal hd (mnt/sda1) or external hd or usb flash drive (could be /mnt/sdc1 e.g). Variable $MYRSHROXAPPS always has the right value to let me run any RoxApp program stored in $MYRSHROXAPPS.

Code: Select all

root# echo $MYRSHROXAPPS
/mnt/home2/RoxApps/RSH
root#
I have three /mnt/home's:

- /mnt/home (/mnt/home1)
- /mnt/home2
- /mnt/home3

If there's three partitions on the boot drive, they will all have different values. If there's just on partition /mnt/home2 and /mnt/home3 are pointing to /mnt/home (in RAM only !!!).

My scripts always will find and know their external location or external location of its data files used.

I have some more of stuff like this which is dedicated to make my work much easier. There's a scripting library (P.S.Library) that gives me useful functions as global environment variables.

Code: Select all

root# psl_
Display all 110 possibilities? (y or n)
psl_1stucase          psl_funcs             psl_getwinpos         psl_mylang            psl_setvmgroup
psl_all1stucase       psl_getappcategory    psl_getwinsize        psl_mypup             psl_setvolume
psl_all1stucasers     psl_getappcomment     psl_getwp             psl_noext             psl_setwingeo
psl_backupinitrd      psl_getappexec        psl_icon2script       psl_noextbn           psl_setwinpos
psl_bin2morse         psl_getappgenname     psl_imageviewer       psl_okmsg             psl_setwinsize
psl_cleaninitrd       psl_getappicon        psl_info              psl_okmsg1            psl_setwp
psl_cleansfsbackup    psl_getappicon4gtk    psl_initwingeo        psl_okmsg2            psl_slideshow
psl_cleantemp         psl_getappname        psl_jwmpiperefresh    psl_opendir           psl_soft_wallpapers
psl_cleantmp          psl_getcfgfile        psl_launcher          psl_qr                psl_sortlist
psl_cleantopless      psl_getcfgfileprefix  psl_legend            psl_quickpoweroff     psl_sound
psl_combobox          psl_getdrivefrompath  psl_lp2prefix         psl_quickreboot       psl_soundrec
psl_date              psl_getdriveonly      psl_makerunscript     psl_recordx2avi       psl_spacereplace
psl_date4filename     psl_getfirstchar      psl_mdselect          psl_replace           psl_stoprec
psl_deskrefresh       psl_getfreedrivemem   psl_mfselect          psl_savewinsize       psl_strlcase
psl_dev               psl_getinputsource    psl_midiconnect       psl_screenframe       psl_strlen
psl_development       psl_getlineswitch     psl_mkgettext         psl_screenh           psl_strucase
psl_dirdir            psl_getlp2prefix      psl_mkmenu            psl_screenshot        psl_text2bin
psl_drivelist         psl_getmntpath        psl_mkmenutreewidget  psl_screenw           psl_time
psl_edit              psl_getpuprodir       psl_mkprj2menu        psl_setdesktop        psl_tree
psl_errmsg            psl_getvar            psl_mkprjmenu         psl_setinputsource    psl_wincenter
psl_extonly           psl_getvolume         psl_mksvgbutton       psl_setlineswitch     psl_xdte
psl_fixmenus          psl_getwingeo         psl_mksvgguihead      psl_setmcvolume       psl_yesno
root#
I can use each of this function without to use source or to include the scripting library into my programs.

Code: Select all

root# psl_setwingeo --help
Function psl_setwingeo
 - setting position and size of active Window
 - needs 4 Values:    .
No Values are exported.
 
 Usage: psl_setwingeo $NEWXPOS $NEWYPOS $NEWWPOS $NEWHPOS;


root#

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

Hello again, all.

Just a word to tell you that I have edited my initial post and script above.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply