Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 10837  / 2 Years ago, fri, november 26, 2021, 11:18:40

I have two scripts - one to mount some folders over SSHFS - and one to unmount.



I would like to launch the mount script when my default Ubuntu desktop is launched (after I log in at the graphical console) - and the unmount script when I "Log Out..." from the cog-wheel at the top-right of the desktop.



Please can someone tell me how to achieve this? What are the most convenient/standard hooks to run commands on desktop launch / exit?


More From » unity

 Answers
6

The solution was to use upstart tasks. I required two tasks - one fired when the desktop initializes for a user; the second when the users session expires. The following two scripts work for me under Ubuntu 14.04.



In ~/.config/upstart/desktopOpen.conf



description "Desktop Open Task"
start on desktop-start
task
script
# Commands to mount sshfs go here as shell-script.
end script


In ~/.config/upstart/desktopClose.conf



description "Desktop Close Task"
start on session-end
task
script
# Commands to unmount sshfs go here as shell-script.
end script


My fingers are crossed that these events will continue to meet requirements in future Ubuntu releases. I thought it worth posting my solution here - in case it is of use to others.


[#23437] Saturday, November 27, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brasiplacar

Total Points: 314
Total Questions: 124
Total Answers: 97

Location: Dominican Republic
Member since Wed, Mar 17, 2021
3 Years ago
;