Run shell script after XServer is started?
According to this link .xinitrc in your home directory will be read and executed, otherwise the default /etc/X11/xinit/xinitrc
is used. So you should be able to create this file and have the shell script started.
Execution of some command every time a xerser starts: Turn on keyboard leds on startup by `xset led led on`
You could edit the /etc/rc.local file which will be executed after boot and run level changes. You can just throw the command right in there. You may also be able to use ~/.xinitrc or ~/.xsession depending on your specific setup (I'm not familiar with Ubuntu Mate).
How to run a shell script at startup
The file you put in /etc/init.d/
have to be set to executable with:
chmod +x /etc/init.d/start_my_app
As pointed out by @meetamit, if it still does not run you might have to create a symbolic link to the file in /etc/rc.d/
ln -s /etc/init.d/start_my_app /etc/rc.d/
Please note that on the latest versions of Debian, this will not work as your script will have to be LSB compliant (provide at least the following actions: start, stop, restart, force-reload, and status):
https://wiki.debian.org/LSBInitScripts
As a note, you should always use the absolute path to files in your scripts instead of the relative one, it may solve unexpected issues:
/var/myscripts/start_my_app
Finally, make sure that you included the shebang on top of the file:
#!/bin/sh
running shell script starts new shell instead of running the shell script
The key was this line in /etc/bash.bashrc
source /usr/sbin/start-systemd-namespace
Awhile back I got systemd working from some instructions elsewhere on the net. It must have added this line. It causes an entirely new shell to start when you're using another shell like zsh. After commenting it out, voila, no more problem.
Related Topics
Sed to Loop Through File and Replace Placeholder Variables
I Need a Binary Comparison Tool for Win/Linux
Print The Lines Between Two Dates from The Log Using Shell Command in Linux
Git Clone Using Ssh Failed in Windows Due to Permission Issue
User Time Larger Than Real Time
Will Java Compiled in Windows Work in Linux
Building Gcc with Glibc in a Non-Standard Location Without Root
How Many Objects Are Returned by Aws S3API List-Objects
How Is an Error Reported from Async Socket Connect
Awk: Find and Replace in Certain Field Only
How to Simulate a Iret on Linux X86_64
Nasm X86_64 Assembly in 32-Bit Mode: Why Does This Instruction Produce Rip-Relative Addressing Code
How to Execute a Command in a Bash Script and Then Focus The Appearing Window
Compile Errors Using Bfd.H on Linux
List Files That Are in Directory1 But Not in Directory2 and Vice Versa