linuxmint - Run scripts on start or end of xsession -
i trying find way run script on sleep before x session ends, because script requires active x session execute properly. storing script in /etc/pm/sleep.d
did not work (and returned errors related non-existent x session). ideas put script?
update in response comments
king@death-star /etc/acpi $ cat 01_revert_kb_on_sleep #!/bin/bash touch ~/desktop/touchfile_my_script_acpi case "$1" in hibernate|suspend) sh -c "/home/king/desktop/scripts/rotate_desktop normal; /home/king/desktop/scripts/misc/my_keyboard on" 2> ~/desktop/revert_kb_error_log.txt ;; #thaw|resume) king@death-star /etc/acpi $ ls total 1mb drwxr-xr-x 3 root root 1mb jun 11 23:36 . drwxr-xr-x 163 root root 1mb jun 11 23:41 .. -rwxr-xr-x 1 root root 1mb jun 11 23:36 01_revert_kb_on_sleep king@death-star /etc/acpi $ ps -ef| grep acpid root 1070 1 0 23:41 ? 00:00:00 acpid -c /etc/acpi/events -s /var/run/acpid.socket king 3499 2574 0 23:52 pts/2 00:00:00 grep --colour=auto acpid
step 1.
a. enable , start acpi
service.
b. run acpi_listen
command , try putting computer sleep via various methods (pushing power button, closing lid, etc.)
c. find out events triggered, when above. in case were: button/lid lid close
, button/sleep sbtn 00000080 00000000
step 2.
a. create file /etc/acpi/events/my_events
following:
event=(button/sleep sbtn|button/lid lid close) action=/etc/acpi/my_script.sh
substitute events in event=
line events.
b. create file /etc/acpi/my_script.sh
following:
#!/bin/sh /home/king/desktop/scripts/rotate_desktop normal /home/king/desktop/scripts/misc/my_keyboard on
nb. might need add export display=:0
before scripts access x session.
nb2: scripts run root
user credentials. run user credentials, might want do:
sudo -u king /home/king/desktop/scripts/rotate_desktop normal sudo -u king /home/king/desktop/scripts/misc/my_keyboard on
c. make file /etc/acpi/my_script.sh
executable:
chmod +x /etc/acpi/my_script.sh
d. restart acpi
service.
step 3. share , enjoy.
Comments
Post a Comment