Categories
Apple

HOWTO: Fix missing Thumbnails in Finder

I recently upgraded to macOS Monterey (yeah, finally) and immediately noticed that previews of new images weren’t showing up in Finder.

Old images did have a preview image so something was wrong with how previews were generated.

Searching online, I found a few solutions, including one that involved deleting the Finder configuration file (plist file) which may have worked in 2009 or 2012 but that was long ago and it doesn’t work now.

So, to save you doing that and having to resize your favourite Finder windows and configure settings again, the answer is very simple and I found it here.

Load up Activity Monitor and search for com.apple.quicklook.ThumbnailsAgent. Double click on it and force it to quit.

CMD-right click on Finder in the dock and relaunch Finder and your thumbnails should now appear in all their tiny glory.

I’m writing this here because apparently this happens to people over and over again. While it’s the first time I’ve seen this problem it probably won’t be the last.

Categories
Life

Your mouse is too small

Prompted by someone sharing this tweet at work I decided to try making the mouse cursor on my machine bigger.

On a Mac go to System Preferences->Accessibility->Display->Cursor.

I only bumped the size up one notch, but it’s made a nice change and really makes a difference to the “feel” of the mouse cursor when hovering over text containing links.

After doing that I wondered what else I could do. I left the display at it’s default resolution but in Firefox I did increase the minimum font size, and that has made some websites more pleasant to use.

My son uses a 15.6″ laptop screen with tiny fonts I can barely read when I’m sitting at his desk. I know I used to do that too in my twenties on a Linux desktop using Netscape Navigator but times change and my eyes change. This blog has been going more than twenty years. I wonder what accessibility features I’ll be writing about in another twenty years, eh?

Categories
Ireland

Putting Accents on Characters on Mac

Accents, everyone has one but some characters have more than one, and writing them on a Mac can be hard unless you know how.

I really only need one type of accent, the “sine fada” in Irish that goes over the vowels. They look like this: á, é, ó, ú and í.

For a long time I used Option-key using an Irish keyboard map I got off Justin Mason years ago. I haven’t used it for some time now and every now and again I wonder if there’s a better way of doing it using the standard keyboard maps on a Mac.

Turns out there is.

This page explains how to use the accent menu, but you can also use “dead keys” to type accents.

The accent menu is dead simple. Press the key down for a little longer than usual and a menu will appear with the accents required. Press the corresponding number and your accented character appears!

The dead key approach is probably faster however. Use the keyboard viewer to see your keyboard layout. I have a large split Microsoft keyboard and I’m using the British PC layout now so when I hit the Option key the accents are highlighted.

If I want to type “I like to eat cake” in Irish, and not “I like to eat shit”, I must use “Option-e” followed by “a” to get “á” in one word:

“Is maith liom cáca a ithe.”

I’m sure by now you’ve realised just how important accents are in daily life. It’s the difference between delicious chocolate and something that looks similar but tastes quite different. Yeah, you really needed that mental image didn’t you? Sorry. 🙂

Categories
Linux

Rsync between Mac and Linux

99.999999% of my readers can probably ignore this one, but if you are of the small minority who use Rsync and have Mac and Linux computers in your home you’ll want to read this.

I have Plex running on a Raspberry Pi for my music. I have a large mp3 folder. Too large to run Syncthing on it unfortunately, but an occasional rsync is perfectly fine.

I thought it worked fine until I quickly realised it was syncing the same files over and over again. It turns out the Mac and Linux machines I’m using have different ideas about character sets their filenames are stored in. A file with an accented character on the Mac is completely different to one that looks the same on the Linux box.

The solution took a while for me to find but it’s very simple. Rsync has an option named --iconv to convert between character sets!

The solution was embarrassingly simple: Much due to a comment I read when researching the problem, I thought you were supposed to specify the character set in the order of transformation; but it seems as that is not the correct syntax. Rather, one should always use --iconv=utf-8-mac,utf-8 when initialising the rsync from the mac, and always use --iconv=utf-8,utf-8-mac when initialising the rsync from the linux machine, no matter if I want to sync files from the mac or linux machine.

Then it works like magic!

EDIT: Indeed, sometimes, checking the manual page closely is a good thing to do. Here it is, black on white:

--iconv=CONVERT_SPEC
              Rsync  can  convert  filenames between character sets using this
              option.  Using a CONVERT_SPEC of "." tells rsync to look up  the
              default  character-set via the locale setting.  Alternately, you
              can fully specify what conversion to do by giving a local and  a
              remote   charset   separated   by   a   comma   in   the   order
              --iconv=LOCAL,REMOTE, e.g.  --iconv=utf8,iso88591.   This  order
              ensures  that the option will stay the same whether you're push-
              ing  or  pulling  files.

Categories
Photography

HOWTO: Square Instagram images with white borders

I noticed that a lot of Instagram users, such as Alan Schaller to name but one, were posting images with thick white borders to make their images into the square images that Instagram favours. I like the striking look these images have in the Instagram gallery.

I wondered for some time about the best way of adding this border and from brief searches there are apps that will add the border but my workflow involves Lightroom so I wanted to integrate the border making into my export process.

I work on a Mac, and already have ImageMagick installed so I knew a little shell scripting would probably go a long way.

A couple of searches later, and I found this page describing how to use ImageMagick to create a floating image within a square canvas without changing the aspect ratio of the image.

Instagram resizes to 1080px wide so by using the following code I could make a rectangular image into a square:

convert -background white -gravity center input.jpg \
     -resize 1080x1080 -extent 1080x1080 result.jpg

Here’s an example from my street photo today. See it on Instagram here.

Once I could do that, the rest was simple. I have a Lightroom export for Instagram images that resizes them and places them in a folder where they are synced automatically with my phone using Syncthing.

Export actions have a “post processing” section where Lightroom can call an external script. I created the following script, made it executable with chmod a+x add_instagram_border.sh and added to Lightroom using “Open in Other Application”.

#!/bin/sh

# Square and add white borders to images.
# https://odd.blog/

for i in "$@"
do
    /usr/local/bin/convert -background white -gravity \
        center "$i" -resize 1080x1080 -extent 1080x1080 \
        /tmp/out.jpg
    mv /tmp/out.jpg "$i"
    open "~/Sync/Instagram"
done

The script goes through the exported images from Lightroom, adding borders to them, and then at the end opens the folder in Finder for review.

Hopefully this will be useful to someone else. If you add borders to your images, how do you do it?

Categories
Apple

error: btn: invalid btn_btree.bt_key_count

I recognised the symptoms:

  1. Excessive disk trashing.
  2. General slow down.
  3. Backblaze and Time Machine causing the rainbow spinner.

My filesystem needed first aid. I think I can trace this back to the latest macOS update. I swear that half the updates cause filesystem corruption of some sort, but it also feels like I’m running First Aid at least once a month anyway!

Unfortunately for me, the error this time was:

error: btn: invalid btn_btree.bt_key_count

Apparently Diskutil can’t fix that error. The only thing you can do is erase the drive, reinstall MacOS and then restore your data. I was dreading it.

I have a Time Machine backup but I decided to make another backup of my home directory, while logged into another account. Lucky I did as an IO error showed up in Library/Caches/ – thankfully I think in an Apple app I don’t use.

I expected the business of restoring everything to be awful, but in the end the MacOS installer fired up Migration Assistant which let me restore my last Time Machine backup.

With that done it was time to install Brew again. The first package to go back in was coreutils but “brew reinstall” has a bug where it won’t accept parameters. I should have used “install” but “reinstall” with  “–with-default-names” doesn’t work. Also coreutils and related packages are “keg-only” now so no symlinks to /usr/local/bin are made. You have to run “brew link” to link all the commands. It was a simple job then to rename each file, removing the “g” prefix.

I’ll find more things as I go that aren’t configured I’m sure, but thankfully restoring from Time Machine made the job much easier!

Categories
Apple

High Sierra and coreutils

Since MacOS High Sierra has been out for a long time this is probably old news to the tiny minority using coreutils. When you upgrade you might find that “df” and other commands don’t work properly.

Every time I opened a terminal after upgrading I saw errors saying commands had been aborted. When I ran “df” it would abort immediately.

I thought the upgrade had damaged my filesystem, especially since it introduced APFS. I ran “First Aid” in Disk Utility several times, both live and in recovery.

It then occurred to me to try the MacOS df in /bin/. It worked!

Coreutils is the package that includes lots of command line tools like “df”. I installed it using brew so the following fixed the problem:

brew reinstall coreutils

I noticed it put everything in /usr/local where my original commands were in /opt/ so changing the PATH in my .zshrc was necessary too. Everything was back to normal again! 🙂

EDIT: Some other commands were messed up. “find” had changed, but then I realised it probably isn’t in coreutils and I was using the MacOS version. This page led me to the right package names and the following command line:

brew reinstall coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt --with-default-names

The “–with-default-names” parameter restores the original filenames, removing the “g” prefix. Everything outside of the coreutils went in /usr/local/bin/ which I made sure was added to the path too.

Categories
Tech

Unmount USB drives from a script in macOS

I have a number of external drives hanging off my laptop, but sometimes I want to disconnect them. I used to go into Finder and click the eject button but I have five drives now so that’s getting unwieldy.

There are a few different ways of doing this. I wrote a small BASH script based on information here.

I created a shell script on my Desktop, added the following, changing DRIVE to the volume path for each of my external drives:

osascript -e ‘do shell script “diskutil unmountDisk /Volumes/DRIVE”‘

After creating that script I made it executable with chmod +x and as I use iTerm2 as a terminal I associated .sh files with that (Finder, right click on script, Get Info->Open With).
Every time I double click the script a new tab opens in iTerm2 and I see the progress of the unmount commands!

Categories
Tech

Remapping the Keyboard on a new Macbook Pro

I must have an odd keyboard, at least for one that’s paired with a Mac. It’s a Microsoft split keyboard and has a bunch of extra keys that aren’t on a Macbook Pro keyboard, like a dedicated # key and the keys are all over the place compared to the laptop keyboard. But I like it that way.

I’ve heard comments from people who use my laptop and they are confused by how shift-2 doesn’t print @ but ” instead, and the key by the left shift prints \ instead of ~ (which is over by the Return key). They’ll say, “Oh, it’s some sort of PC keyboard?” Well, yeah.

This is not the first time I’ve had to fix my keyboard. A long time ago Justin Mason created a useful Irish Fixed Keyboard Layout, but for some reason with this latest hardware upgrade it wasn’t working exactly as planned. The #, \ and ` keys were mixed up. Luckily, with the help of the Key Codes app I could detect the the key code of the physical key pressed. For example, the key next to the left shift is key code 10 so it was just a matter of editing the keyboard layout in a text editor and changing that to output “\”. Logout and login to refresh and the key works!

What’s odd, is that this keyboard layout has served me well for almost a decade and didn’t need editing, which is why I’m documenting it in this post.

I looked at both Ukelele and Karabiner but the former looked overwhelming (yeah, then I went editing XML by hand..) and the latter doesn’t work in macOS Sierra (there’s a simplified “elements” version for Sierra). Then I thought I should just edit the keyboard mapping directly. 🙂

Categories
Linux

Find Duplicate Files in MacOS

In the past I’ve used FSLint or even some BASH magic to find duplicate files but I have a huge archive of photos and videos, some of which were renamed during import, and some were accidentally imported more than once, or moved about. It’s somewhat chaotic

dupeguru

So I was very glad to find dupeGuru! It’s a powerful application for MacsOS and Linux that allows you to scan one directory or more for duplicate files. It can search by content, or match filenames. It has modes for music and pictures, but I’ve stuck with the standard search as I want to only look for files that are 100% the same.

It found several gigabytes of duplicates for me, and it has a useful feature that symlinks duplicates to their parent. Even though the dupes still exist, they’re not taking up any space.

The developer is looking for help to maintain the project. You can find more information and source code too on the dupeGuru GH page.