Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 13 Nov 2019, 17:19
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Picking up all the default execs in /etc/profile.local
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
musher0

Joined: 04 Jan 2009
Posts: 14455
Location: Gatineau (Qc), Canada

PostPosted: Mon 17 Dec 2018, 01:34    Post subject:  Picking up all the default execs in /etc/profile.local  

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:
# /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:
#!/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:
$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. Sad
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.
etc-edited-profile.zip
Description 
zip

 Download 
Filename  etc-edited-profile.zip 
Filesize  1.76 KB 
Downloaded  118 Time(s) 

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)

Last edited by musher0 on Mon 17 Dec 2018, 23:07; edited 1 time in total
Back to top
View user's profile Send private message 
ITSMERSH

Joined: 02 May 2018
Posts: 911

PostPosted: Mon 17 Dec 2018, 12:11    Post subject:  

Ein Bild sagt mehr als 1000 Worte! Wink
Screenshot.jpg
 Description   
 Filesize   160.1 KB
 Viewed   191 Time(s)

Screenshot.jpg


_________________
RSH

Beware of the Dog ähem nic007! Wink
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 14455
Location: Gatineau (Qc), Canada

PostPosted: Mon 17 Dec 2018, 13:35    Post subject:  

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
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
ITSMERSH

Joined: 02 May 2018
Posts: 911

PostPosted: Mon 17 Dec 2018, 15:22    Post subject:  

Hi musher0.

Quote:
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:
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:
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:
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:
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#

_________________
RSH

Beware of the Dog ähem nic007! Wink
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 14455
Location: Gatineau (Qc), Canada

PostPosted: Mon 17 Dec 2018, 23:09    Post subject:  

Hello again, all.

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

BFN.

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0448s ][ Queries: 12 (0.0056s) ][ GZIP on ]