how to manage userscripts
#1
Tongue 
hello, I need a beginners help or a tutorial, to learn sxmo's user scripts, please [Image: tongue.png]

1) I am too stupid to be able to ssh to my pinephone (from OSX)
2) installed Thunar and found my empty unserscripts folder
3) would like to locate userscripts and copy them to my userscropts folder
4) on edit userscripts and ../ I get a list of contacts.tsv, hooks/, userscripts/, xinit of course, none of these menus does anything, probably because my userscripts folder is empty.

Now if I could locate some scripts in the internet, download them, and copy them into the userscripts folder (with firefox and thunar), I imagine that might be a first step. Later do the same via ssh. Are there any helpful links for shell scripting and sxmo scripts?

On https://git.sr.ht/~mil/ I see much about scripting but very few that I can understand ;(
There seems to exist a script to sleep the phone after a while. I would like to install it and see what it does.
  Reply
#2
The userscripts can do anything you want from the command line.

Here's mine that just provides a way to run my backup script from the userscripts menu.

/home/user/.config/sxmo/userscripts/backup:
Code:
#!/usr/bin/env sh
exec /home/user/ph_backup/backup

My backup script calls rsync to copy /home/user to my linux PC over ssh.  It also saves a list of installed packages.

/home/user/ph_backup/backup:
Code:
#!/usr/bin/env sh

set -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
EXCLUDE_FILE="$SCRIPT_DIR/backup.exclude"
BACKUP_DIR=/home/user
STATE_DIR=/home/user/backup_state
DEST=myuser@myhost.domain.com:/home/myuser/backup/ph/data

mkdir -p $STATE_DIR
rm -f $STATE_DIR/*.prev
if [ -f "$STATE_DIR/start_time" ]; then
    mv -f $STATE_DIR/start_time $STATE_DIR/start_time.prev
fi
if [ -f "$STATE_DIR/finish_time" ]; then
    mv -f $STATE_DIR/finish_time $STATE_DIR/finish_time.prev
fi
date --iso-8601=seconds >$STATE_DIR/start_time
nice time rsync -av --stats --log-format="%o %b %f %l" -H --delete --delete-excluded --exclude="$STATE_DIR/**" --exclude-from=$EXCLUDE_FILE $BACKUP_DIR $DEST >$STATE_DIR/backup.log 2>&1
apk list >$STATE_DIR/packages.txt
date --iso-8601=seconds >$STATE_DIR/finish_time
nice time rsync -av --stats --log-format="%o %b %f %l" -H --delete --delete-excluded --exclude=$STATE_DIR/backup_state.log $STATE_DIR $DEST >$STATE_DIR/backup_state.log 2>&1

Here is backup.exclude:
Code:
.cache/**
.surf/cache/**
  Reply
#3
thank you! Now do I understand correct I can copy such a script to /home/user/.config/sxmo/userscripts/ so it will appear in the menu and I can trigger it from there?
  Reply
#4
Userscripts I figured out, but I'd like to know how the apps hook works.
  Reply
#5
Unfortunately, I think that some familiarity in one or more scripting language(s) would almost be a prerequisite to using something like SXMO (or dwm it's based on, or other similar tools following Unix and/or Suckless philosophy).

That's going to be a step learning curve for any newcomer, however the more you learn the more control you will be able to take back over your computing. Not just on phone, but anywhere GNU/Linux runs (desktop, server, Single Board Computer, etc.

If you want to learn about bash, I can recommend just hanging out in #bash (on Libera IRC network), and studying the Wooledge FAQ they have linked in the MoTD.

Python is another candidate, but usually this is for more involved things, as you are potentially getting into Object Oriented (OO) paradigm which may really be confusing to a newcomer. Probably best to stick to simple, imperative languages like shell scripting at first.
Cheers,
TRS-80

What is Free Software and why is it so important for society?

Protocols, not Platforms

For the most Linux-y experience on your Linux phone, try SXMO!

I am (nominally) the Armbian Maintainer for PineBook Pro (although severely lacking in time these days).
  Reply
#6
(07-13-2021, 03:03 PM)KavusKazian Wrote: ... but I'd like to know how the apps hook works.

anyone?
  Reply
#7
To create your own app hook in sxmo (edit app menu entry):

Code:
cp /usr/share/sxmo/default_hooks/sxmo_hook_apps.sh ~/.config/sxmo/hooks/


in there
Code:
nano ~/.config/sxmo/hooks/sxmo_hook_apps.sh

you can edit entries, for example adding osmin to the menu:

Code:
write_line_app osmin "$icon_glb osmin" "osmin"


to search for icon names you can run:

Code:
nano /usr/share/sxmo/default_hooks/sxmo_hook_icons.sh
  Reply
#8
Thanks for sharing solution!

The "built-in" app selection is somewhat limited, if you think the app you added might be generally useful, please consider submitting a patch to the SXMO project!

Cheers!
Cheers,
TRS-80

What is Free Software and why is it so important for society?

Protocols, not Platforms

For the most Linux-y experience on your Linux phone, try SXMO!

I am (nominally) the Armbian Maintainer for PineBook Pro (although severely lacking in time these days).
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Hooks and userscripts: POST 'EM! MungFuSensei 0 1,358 01-27-2021, 09:38 PM
Last Post: MungFuSensei

Forum Jump:


Users browsing this thread: 1 Guest(s)