Discussion:
photolibraryd
(too old to reply)
Király
2019-08-16 16:15:26 UTC
Permalink
Spouse and I share the same Photos library between our two user accounts
on the same Mac (MacOS 10.13.6, Photos 3.0.) Library is on an external
volume with ownership ignored.

After one of us uses (and quits) Photos, photolibraryd continues
running, and the other user can't open the library. We have to either
force quit the photolibraryd process using Activity Monitor, or log out
the other user. Any way around this? Why does photolibraryd keep running
after the user has quit the app?
--
K.

Connection closed by foreign host.
~BD~
2019-08-16 16:25:35 UTC
Permalink
Post by Király
Spouse and I share the same Photos library between our two user accounts
on the same Mac (MacOS 10.13.6, Photos 3.0.) Library is on an external
volume with ownership ignored.
After one of us uses (and quits) Photos, photolibraryd continues
running, and the other user can't open the library. We have to either
force quit the photolibraryd process using Activity Monitor, or log out
the other user. Any way around this? Why does photolibraryd keep running
after the user has quit the app?
Is there some reason for you not upgrading to the current OS - 10.14.6
and current Photos which is Version 4.0 (3461.7.140)?

Perhaps if you upgrade, all will work as you wish!

Good luck! :-)
--
David B.
Devon
Jolly Roger
2019-08-16 16:41:04 UTC
Permalink
Post by Király
Spouse and I share the same Photos library between our two user accounts
on the same Mac (MacOS 10.13.6, Photos 3.0.) Library is on an external
volume with ownership ignored.
After one of us uses (and quits) Photos, photolibraryd continues
running, and the other user can't open the library. We have to either
force quit the photolibraryd process using Activity Monitor, or log out
the other user. Any way around this? Why does photolibraryd keep running
after the user has quit the app?
It's possible that behavior is due to a bug. It's also possible that
Apple hasn't considered this use case (two users sharing the same
library on a volume whose ownership & permissions are ignored.

Seems like a great candidate for a bug report.
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
Király
2019-08-17 04:44:31 UTC
Permalink
Post by Jolly Roger
It's possible that behavior is due to a bug. It's also possible that
Apple hasn't considered this use case (two users sharing the same
library on a volume whose ownership & permissions are ignored.
Seems like a great candidate for a bug report.
Yeah, but I doubt Apple will fix this for me. I'm using a 10 year old
iMac, so stuck on High Sierra. Was hoping for a homemade solution, like
some way to automate the force quitting of photolibraryd when the Photos
app is quit.
--
K.

Connection closed by foreign host.
gtr
2019-08-17 05:49:36 UTC
Permalink
Post by Király
Post by Jolly Roger
It's possible that behavior is due to a bug. It's also possible that
Apple hasn't considered this use case (two users sharing the same
library on a volume whose ownership & permissions are ignored.
Seems like a great candidate for a bug report.
Yeah, but I doubt Apple will fix this for me. I'm using a 10 year old
iMac, so stuck on High Sierra. Was hoping for a homemade solution, like
some way to automate the force quitting of photolibraryd when the Photos
app is quit.
I have no idea if it will fix your oddities but sometimes Photos sorts
out occasional lunacy by rebuilding the library. I think you hold down
option while starting the program. Or maybe it's command.
Jolly Roger
2019-08-17 17:00:31 UTC
Permalink
Post by Király
Post by Jolly Roger
It's possible that behavior is due to a bug. It's also possible that
Apple hasn't considered this use case (two users sharing the same
library on a volume whose ownership & permissions are ignored.
Seems like a great candidate for a bug report.
Yeah, but I doubt Apple will fix this for me. I'm using a 10 year old
iMac, so stuck on High Sierra. Was hoping for a homemade solution,
like some way to automate the force quitting of photolibraryd when the
Photos app is quit.
That's easy to do with most scripting languages, including AppleScript.
Put this code into a new Script Editor window and save it as Format:
Application with the Stay open after run handler option enabled. Then
you can run it at login by adding it to your System Preferences > Users
& Groups > Login Items panel:

-- begin script
property waiting : false

on run
set waiting to false
end run

on idle
if waiting then
if not AppIsRunning("Photos") then
set pid to ProcessIsRunning("photolibraryd")
if pid is not "" then
set killResults to do shell script ("kill -9 " & pid as text)
if killResults is not "" then
tell application "System Events" to display alert "Potential Error" message ("Kill command returned unexpected results: " & return & return & killResults as text) buttons {"Thanks"} default button 1
end if
end if
end if
else
if AppIsRunning("Photos") then
set waiting to true
end if
end if

return 1
end idle

on AppIsRunning(appName)
tell application "System Events"
set isRunning to (appName is in (name of every process))
end tell
return isRunning
end AppIsRunning

on ProcessIsRunning(processName)
set pid to ""
try
set pid to do shell script ("pgrep " & processName as text)
end try
return pid
end ProcessIsRunning
-- end script
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
Király
2019-08-17 22:29:06 UTC
Permalink
Post by Jolly Roger
Put this code into a new Script Editor window
Wow Roger, I'm always so impressed by people who know how to write
Applescripts, and even more impressed when they can whip them up so fast
to solve a problem for me! Many thanks, I'll try that out.
--
K.

Connection closed by foreign host.
Jolly Roger
2019-08-18 22:40:30 UTC
Permalink
Post by Király
Post by Jolly Roger
Put this code into a new Script Editor window
Wow Roger, I'm always so impressed by people who know how to write
Applescripts, and even more impressed when they can whip them up so
fast to solve a problem for me! Many thanks, I'll try that out.
Welcome. : )
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
Király
2019-08-22 15:34:08 UTC
Permalink
Post by Jolly Roger
Welcome. : )
Hi JR,

The script sort of works intermittently. If often fails with this error:
sh: line 0: kill: 49979
49986: arguments must be process or job IDs

Do you know what's wrong?
Thank you.
--
K.

Connection closed by foreign host.
Jolly Roger
2019-08-22 15:52:22 UTC
Permalink
Post by Király
Post by Jolly Roger
Welcome. : )
Hi JR,
sh: line 0: kill: 49979
49986: arguments must be process or job IDs
Do you know what's wrong?
Thank you.
It looks like pgrep returned two PIDs, which must mean there are two
photolibraryd processes running at the time. Could it be that Photos was
open in two macOS user accounts at the time?

At any rate, I've modified the script to handle that case by killing
each process in the list:

-- begin script
property waiting : false

on run
set waiting to false
end run

on idle
if waiting then
if not AppIsRunning("Photos") then
set processIDs to ProcessIsRunning("photolibraryd")
repeat with nextPID in the paragraphs of processIDs
if nextPID is not "" then
set killResults to do shell script ("kill -9 " & nextPID as text)
if killResults is not "" then
tell application "System Events" to display alert "Potential Error" message ("Kill command returned unexpected results: " & return & return & killResults as text) buttons {"Thanks"} default button 1
end if
end if
end repeat
end if
else
if AppIsRunning("Photos") then
set waiting to true
end if
end if

return 1
end idle

on AppIsRunning(appName)
tell application "System Events"
set isRunning to (appName is in (name of every process))
end tell
return isRunning
end AppIsRunning

on ProcessIsRunning(processName)
set processIDs to ""
try
set processIDs to do shell script ("pgrep " & processName as text)
end try
return processIDs
end ProcessIsRunning
-- end script
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
gtr
2019-08-23 04:49:53 UTC
Permalink
Post by Jolly Roger
Post by Király
Post by Jolly Roger
Welcome. : )
Hi JR,
sh: line 0: kill: 49979
49986: arguments must be process or job IDs
Do you know what's wrong?
Thank you.
It looks like pgrep returned two PIDs, which must mean there are two
photolibraryd processes running at the time. Could it be that Photos was
open in two macOS user accounts at the time?
At any rate, I've modified the script to handle that case by killing
-- begin script
property waiting : false
on run
set waiting to false
end run
on idle
if waiting then
if not AppIsRunning("Photos") then
set processIDs to ProcessIsRunning("photolibraryd")
repeat with nextPID in the paragraphs of processIDs
if nextPID is not "" then
set killResults to do shell script ("kill -9 " & nextPID as text)
if killResults is not "" then
tell application "System Events" to display alert "Potential
Error" message ("Kill command returned unexpected results: " & return &
return & killResults as text) buttons {"Thanks"} default button 1
end if
end if
end repeat
end if
else
if AppIsRunning("Photos") then
set waiting to true
end if
end if
return 1
end idle
on AppIsRunning(appName)
tell application "System Events"
set isRunning to (appName is in (name of every process))
end tell
return isRunning
end AppIsRunning
on ProcessIsRunning(processName)
set processIDs to ""
try
set processIDs to do shell script ("pgrep " & processName as text)
end try
return processIDs
end ProcessIsRunning
-- end script
Many you rock!
Jolly Roger
2019-08-23 18:31:47 UTC
Permalink
Man you rock!
Nah! But thanks! : D

One thing I love about AppleScript is how easy it is for someone who
really doesn't know much about software development to understand and
use. On the flip side of that, AppleScript does have significant
idiosyncrasies that tend to complicate things for people who are new to
the language. And knowing how to avoid or work around those potential
issues is often the key to success!
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
gtr
2019-08-24 00:39:19 UTC
Permalink
Post by Jolly Roger
Man you rock!
Nah! But thanks! : D
One thing I love about AppleScript is how easy it is for someone who
really doesn't know much about software development to understand and
use. On the flip side of that, AppleScript does have significant
idiosyncrasies that tend to complicate things for people who are new to
the language. And knowing how to avoid or work around those potential
issues is often the key to success!
I'm sure that's true. I've bought a few books on AppleScript over the
years, and malingered in the earlier chapters. I've then usually found
a way to avoid it with utilties of one kind or another.

In fact, I've been wanting to sit down and write some AScripts to help
hot-key Apple's Numbers application for simple things like "Add Line
Below" and such. When gathering ammo for a first pass, I recently saw
that the program has now added drop-down entries, making it feasible
for me to simply use Keyboard Maestro.

Saved again!
Jolly Roger
2019-08-24 19:27:21 UTC
Permalink
Post by gtr
Post by Jolly Roger
Man you rock!
Nah! But thanks! : D
One thing I love about AppleScript is how easy it is for someone who
really doesn't know much about software development to understand and
use. On the flip side of that, AppleScript does have significant
idiosyncrasies that tend to complicate things for people who are new
to the language. And knowing how to avoid or work around those
potential issues is often the key to success!
I'm sure that's true. I've bought a few books on AppleScript over the
years, and malingered in the earlier chapters. I've then usually
found a way to avoid it with utilties of one kind or another.
In fact, I've been wanting to sit down and write some AScripts to help
hot-key Apple's Numbers application for simple things like "Add Line
Below" and such. When gathering ammo for a first pass, I recently saw
that the program has now added drop-down entries, making it feasible
for me to simply use Keyboard Maestro.
Saved again!
The problem with using a macro utility to automate mouse clicks, key
presses, and so on is you have to avoid doing anything with the device
or you'll screw up the macro and those clicks and key presses will be
misplaced. The nice thing about AppleScript is generally rather than
controlling the user interface, you're sending commands directly to the
app in question, which means it doesn't matter what the user is doing at
the time with the mouse or keyboard. In some cases, though, like when an
app doesn't support a command to do what you want, user interface
automation is the only way to get it done.
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
Király
2019-08-26 15:41:43 UTC
Permalink
Post by Jolly Roger
Nah! But thanks! : D
You do rock, JR!
But there's another bug. While the script is running and I quit Photos,
it fails with this error"

sh: line 0: kill: (70034) - Operation not permitted

Many thanks for all your generous expert help so far.
--
K.

Connection closed by foreign host.
Jolly Roger
2019-08-27 23:09:25 UTC
Permalink
Post by Király
Post by Jolly Roger
Nah! But thanks! : D
You do rock, JR!
But there's another bug. While the script is running and I quit Photos,
it fails with this error"
sh: line 0: kill: (70034) - Operation not permitted
Many thanks for all your generous expert help so far.
I'm betting that's because the process isn't owned by you. The next time
you see that error, find out more about the process by doing a "ps au
PID" (where PID is the process ID in the message).
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR
Loading...