You are not logged in.
Hey Guys,
I made a script for some config in my i3 that contains this commend :
path : /usr/bin/startup
#!/bin/bash
### Set Keyboard Layout
exec "setxkbmap -layout us,ir"
exec "setxkbmap -option 'grp:alt_shift_toggle'"
#monitor
xrandr | grep 'HDMI1 connected' &&
xrandr --output eDP1 --auto --output HDMI1 --auto --left-of eDP1
#set background
while true; do
nitrogen --set-zoom --random /home/mehrdad/Pictures/norway/
sleep 5m
done
and maybe some another thing later. when I want start this script with "./" I got this error :
./startup: line 4: exec: setxkbmap -layout us,ir: not found
and when try to start that as service :
path : /etc/systemd/system/startup.service
[Unit]
Description=Script
[Service]
ExecStart=/usr/bin/startup
[Install]
WantedBy=multi-user.target
I got this error when check service status :
/etc/systemd/system$ sudo systemctl status startup.service
● startup.service - Script
Loaded: loaded (/etc/systemd/system/startup.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2019-05-26 18:47:52 UTC; 4s ago
Process: 2534 ExecStart=/usr/bin/startup (code=exited, status=127)
Main PID: 2534 (code=exited, status=127)
May 26 18:47:52 mskm systemd[1]: Started Script.
May 26 18:47:52 mskm startup[2534]: /usr/bin/startup: line 4: exec: setxkbmap -layout us,ir: n>
May 26 18:47:52 mskm systemd[1]: startup.service: Main process exited, code=exited, status=127>
May 26 18:47:52 mskm systemd[1]: startup.service: Failed with result 'exit-code'.
lines 1-10/10 (END)
but when I run that lines in terminal , expect "#set background" part, I didn't check it yet in termianl, everything work perfectly.
may please help me
Android, Java And Kotlin Developer
and interested to arch linux, go and rust languages
Offline
Why aren't you using xinitrc for this?
Offline
Why aren't you using xinitrc for this?
thanks for reply jasonwryan,
because make challenge for myself and work with services and systemd deeper to improve my knowledge
Last edited by Programmer (2019-05-26 19:06:50)
Android, Java And Kotlin Developer
and interested to arch linux, go and rust languages
Offline
But it really isn't the correct tool for the job. It's like me asking for the best way to screw things with a hammer.
The best place to put such commands is in your ~/.xinitrc.
Offline
plus :
$ help exec
exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
Replace the shell with the given command.
which means the script won't run after first exec command,
and no quotes are required.
Offline
In addition to N_BaH's point, the error message itself is due to the quotes, exce is looking for a callable executable with the name of everything in the quotes - which is nonsense.
Now, wanting to learn to use service files is good, but a omnibus script doing all this different stuff is just not the way to do it. Put the keyboard mapping and xrandr commands in an xinitrc as noted above. But the wallpaper setting command is actually and excellent thing to have systemd do: rather than having a shell looping, just use a systemd timer.
Note that you will want it to be a user timer and you'll have to export a DISPLAY variable. Timers, user services, and exporting variables for systemd services are all well covered in the wiki. Check out the relevant pages, and set up a wallpaper timer with systemd and you'll have gained worthwhile experience using service files.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Online