Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear icon cache for Dock before restarting #9

Closed
daften opened this issue Jan 23, 2018 · 14 comments · Fixed by #17
Closed

Clear icon cache for Dock before restarting #9

daften opened this issue Jan 23, 2018 · 14 comments · Fixed by #17

Comments

@daften
Copy link
Contributor

daften commented Jan 23, 2018

Sometimes my icon cache for dock is corrupt, giving me "weird" icons with the pencils with an A lower right. Clearing the icon cache fixes this problem. This command fixes it right now. Do you think it's worthwhile to add this, maybe with an option? If so, I'll make a PR :)

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;

Solution from https://gist.github.com/fabiofl/5873100
Update: it doesn't work on a high sierra machine.

@fubarhouse
Copy link
Owner

fubarhouse commented Jan 24, 2018

I've got some ideas of how this would work, however I firmly believe it it doesn't work on 10.12.2 and 10.12.3, then we're better off with a different implementation.

If you find a solution I'd be happy to draft it up. I'm doing some googling now which looks like it can work, but not reliably.

Edit: The only one which reliably works appears to be the one below, which requires Recovery mode to be used.

https://gist.github.com/fabiofl/5873100#gistcomment-2232236

Edit (again):

This one looks to be rather easy to implement with seemingly consistent results, but is undertested - what do you think?

https://gist.github.com/fabiofl/5873100#gistcomment-2273003

For that one, I would be happy to add a task in which only executes if, when and before dockutil restarts the Dock process.

@aldanor
Copy link

aldanor commented Aug 22, 2018

Just stumbled upon this as well, any further ideas on this?

@fubarhouse
Copy link
Owner

@aldanor,

Last time I checked there was no 100% solution for this problem, but just hit and miss.

I can have another look around, but I am open to suggestions and PR's if you feel there's an 80% or higher success rate for one implementation.

@fubarhouse
Copy link
Owner

This looks tangible, though I can't speak for backwards compatibility.

I'm interested, but I'd prefer to find a non-sudo way to do this if anybody knows how. If not, I may continue to explore this soon with the use of sudo.

@daften
Copy link
Contributor Author

daften commented Oct 19, 2018

I have this in an aliases file for bash:

# Clear the icon cache for Dock
alias dockiconclear='sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;; sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm -rf {} \;; sudo rm -rf /Library/Caches/com.apple.iconservices.store; echo "Now reboot the system"'

I just perform it manually when needed.

@fubarhouse
Copy link
Owner

In checking for sudo, it's actually no problem to add that because the role makes use of sudo already.

At which point would you ideally prefer to see caches cleared, and under which circumstances would the task be skipped (for idempotence)?

@daften
Copy link
Contributor Author

daften commented Oct 22, 2018

I don't think there's any way to detect this. I always need to reboot after clearing the cache. So I'd propose to put this workaround in the documentation until somebody with more knowledge about this caching mechanism can help out :s

@fubarhouse
Copy link
Owner

@daften,

Sounds good - I'll add a task either before the grunt work when changes are detected or after when no action was taken. I can have this done tonight.

@fubarhouse
Copy link
Owner

@daften,

Feel free to check out branch issue/9.

If you're happy with the implementation let me know, and I'll get a PR in.

Feedback is important, so let me know if and why it wouldn't be suitable.

@daften
Copy link
Contributor Author

daften commented Oct 26, 2018

For reference: master...issue/9

The become_user part in the first changed block is not needed I think, when become: yes is added without become_user, it's always root.

I'd also still add something to the documentation OR add another task to the clear cache handler that prints: please reboot if your dock icons are messed up. Otherwise: looks good, thanks! :)

@fubarhouse
Copy link
Owner

#17 Checks all the boxes here, and tests are passing.

Let me know if you're happy and we'll merge!

@daften
Copy link
Contributor Author

daften commented Oct 28, 2018

Well, I'm clapping my hands, so the song says I'm happy ;)

@fubarhouse fubarhouse mentioned this issue Oct 29, 2018
fubarhouse added a commit that referenced this issue Oct 29, 2018
@daften
Copy link
Contributor Author

daften commented Oct 29, 2018

Thanks @fubarhouse ! ;)

@fubarhouse
Copy link
Owner

No problems 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants