Posts: 307
eugen-b
Joined: 23 Aug 2015
#1
Hello,
I want to run a script at startup and shutdown by placing it in ~/.profile and ~/.bash_logout?
The script is an adaptation of
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://wiki.archlinux.org/index.php/Firefox_on_RAM#The_script"
linktext was:"firefox-sync"
====================================
and the idea is from
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://wiki.archlinux.org/index.php/Firefox_on_RAM#Sync_at_login.2Flogout"
linktext was:"here"
====================================
. It works for me on a different distro with OpenRC, but there the .bash_profile and .bash_logout look much easier than in antiX. It was possible there to simply append ~/.bin/qupzilla-sync at the end of each file. On antiX this didn't have any effect. The script is running well in terminal. The code is FYI:

Code: Select all

#!/bin/sh

static=56ucrisx.default.backup
link=56ucrisx.default
volatile=/dev/shm/palemoon-$USER

IFS=
set -efu

cd ~/.moonchild\ productions/pale\ moon

if [ ! -r $volatile ]; then
    mkdir -m0700 $volatile
fi

if ["$(readlink $link)" !="$volatile" ]; then
    mv $link $static
    ln -s $volatile $link
fi

if [ -e $link/.unpacked ]; then
    rsync -av --delete --exclude .unpacked ./$link/ ./$static/
else
    rsync -av ./$static/ ./$link/
    touch $link/.unpacked
fi
I'm running antiX-16a1.
I know there are other options like cron or with / etc/init.d/rc.local like
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://crunchbang.org/forums/viewtopic.php?id=14453"
linktext was:"here"
====================================
.
But I would prefer a solution in $HOME.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#2
you can put your commands for login at the end of ~/.bashrc.

i assume the same is true for ~/.bash-logout
Posts: 307
eugen-b
Joined: 23 Aug 2015
#3
dolphin_oracle wrote:you can put your commands for login at the end of ~/.bashrc.

i assume the same is true for ~/.bash-logout
Thanks, but putting the command at the end of ~/.bashrc makes it start when I first time open the terminal.

Do you think creating ~/.bash_profile, copying the code from ~/.profile to it and appending my command is a good idea?
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#4
oh, I see what you mean.

I'm really not sure about how the profiles work.

why not just run the script from the regular startup file entries? they will run everytime you log in to a x environment anyway.
Posts: 307
eugen-b
Joined: 23 Aug 2015
#5
Several approaches didn't work:
- creating ~/.config/autostart folder and palemoon-sync.desktop
- editing ~/.desktop-session/autostart
With both the .desktop file and the autostart file I tried different command syntax
/bin/sh ~/bin/palemoon-sync.sh
/bin/bash ~/bin/palemoon-sync.sh
~/bin/palemoon-sync.sh
/bin/sh /home/eugen/bin/palemoon-sync.sh
/bin/bash /home/eugen/bin/palemoon-sync.sh
/bin/sh '/home/eugen/bin/palemoon-sync.sh'
/bin/bash '/home/eugen/bin/palemoon-sync.sh'
I also tried renaming the script deleting .sh ending. Nothing helps.
I made the script executable with chmod x+a. I can launch it with right-click->Execute.
I will now try adding it to JWM autostart.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#6
I believe the startup files are called startup no autostart.

You could also enable xdg autostart in desktop-session.conf
Posts: 307
eugen-b
Joined: 23 Aug 2015
#7
Putting the command sleep 4 && ~/bin/palemoon-sync to JWM autostart worked. I see a folder palemoon-eugen in /dev/shm and the folder in the profile is linked to it. But s.th. is not ok with other solutions. Why does ~/.desktop-session/startup (I mistook the file name in the previous post, but used the right one) not work, wrong syntax?

How do I enable xdg/autostart in desktop-session.conf, where do I find desktop-session.conf? Will use searchmonkey. / etc/desktop-session/desktop-session.conf
Posts: 307
eugen-b
Joined: 23 Aug 2015
#8
Ok, this is likely a bug report:
- I tried putting the command /bin/sh /home/eugen/bin/palemoon-sync & to / etc/desktop-session/startup as well as to ~/.desktop-session/startup. None of these works.
- However I can click"Execute" on / etc/desktop-session/startup and the script runs. (I see the effect in /dev/shm, where a folder with browser profile gets created.)
- The file ~/.desktop-session/startup is not executable. I made it executble by adding #!/bin/bash at the beginning and applying chmod x+a on it. Then I was able to execute startup and got the desired result.
-> Question: Why don't these startup files get executed automatically? I will test if it work with the commad roxterm -e htop in startup file.
Posts: 307
eugen-b
Joined: 23 Aug 2015
#9
No, puting roxterm -e htop into either of both startup files does not show htop at startup. Executing either of the startup files brings up roxterm with htop.

Well, this is what alpha1 is supposed to be. So see this not as a complaint. __{{emoticon}}__

Will test enabling xdg/autostart now.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#10
the startup file do work, its where the volumeicon in the system tray is launched from.


so just doing this doesn't work? The script is set executable correct?
Posts: 307
eugen-b
Joined: 23 Aug 2015
#11
Mine etc/desktop-session/startup looked similar:

Code: Select all

#!/bin/bash
#volumeicon & 
#fbxkb &
#search-bar-icon &
/bin/sh /home/eugen/bin/palemoon-sync &
I mean I tried without /bin/sh, but no result. It is executable, it even launches the script when I right-click the autostart file.
The ~/.desktop-session/startup file initially was not executable, but I made it executable and it looks similar to the above.

Further testing: I enabled xdg/autostart in etc/desktop-session/desktop-session.conf -> LOAD_XDG_AUTOSTART="true" After reboot there was no result. I can execute both etc/xdg/autostart/palemoon-sync.desktop and ~/.config/autostart/palemoon-sync.desktop from right-click and the script starts.

Code: Select all

[Desktop Entry]
Name=palemoon-sync
Exec=/home/eugen/bin/palemoon-sync
Terminal=false
Type=Application
StartupNotify=false
Version=1.0
When I tested I always renamed one file to .bak either in etc or in ~/.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#12
I think you've got something wrong somewhere. This is my / etc/desktop-session/startup file and htop runs fine at login

Code: Select all

#! /bin/bash
volumeicon &

#fbxkb &

#search-bar-icon &

(sleep 5 && toram-eject) &

roxterm -e htop &
Posts: 307
eugen-b
Joined: 23 Aug 2015
#13
From what I can guess I might be missing some daemon which reads these startup files or the /autostart/*.desktop files.
I tested with / etc/xdg/autostart/htop.desktop and ~/.config/autostart/htop.desktop - nothing happens. Executing the .desktop files manually works fine.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#14
Ok more info.

1. ~/.desktop-session/startup is not present by default. Its created when you save your changes in the editor.
2. if ~/.desktop-session/startup is present, the global version in / etc/desktop-session does NOT run.
3. after ~/.desktop-session/startup is created, its still not executable. chmod a+x ~/.desktop-session/startup.

FYI, the window manager specific startup files ALWAYS run. ~/.icewm/startup ~/.fluxbox/startup and ~/.jwm/startup

One of the things requested earlier in the antiX16 thread is that desktop-session configuration be simplified. This is a prime example of why.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#15
eugen-b wrote:From what I can guess I might be missing some daemon which reads these startup files or the /autostart/*.desktop files.
I tested with / etc/xdg/autostart/htop.desktop and ~/.config/autostart/htop.desktop - nothing happens. Executing the .desktop files manually works fine.

i think when you created the home .desktop-session startup files, you used save-all, which probably enabled all the configuration for desktop-session into the home folder. which means you need to change the xdg autostart setting in ~/.desktop-session/desktop-session.conf