Weblog entries 2023

Weblog entries 2023

2023-04-12 Natural breaks in Time Out application for macOS

I'm using a break reminder on macOS, it's called Time Out. https://dejal.com/timeout/

It's a very full-featured app, one of them is that it can skip breaks if it detects a natural break. Meaning, if you go and get a cup of coffee, it counts as a break.

The problem was, that this wasn't working. I found out how to fix this, and I'm documenting it here. Firstly, to see if the app is unable to detect the computer idle, open Time Out, and in the left navigation, select "Advanced". Then turn on "Output scheduler logging" and click the "Open Console" button. This will open Console, the macOS log viewer.

In Console, click the blue Start Streaming button, then in the top right, type: "process: Time Out" and press enter. You should now only see output from Time Out. If you don't move the keyboard or mouse, Time Out should detect that you leave the computer idle. In my case that wasn't happening, it just repeatedly logged the following lines, edited for brevity:

    idle (for 0 secs); Normal due 12/04/2023, 11:19 (in 11 min, 46 secs); .......
    idle (for 0 secs); Normal due 12/04/2023, 11:19 (in 11 min, 45 secs); .......
    idle (for 0 secs); Normal due 12/04/2023, 11:19 (in 11 min, 44 secs); .......

When I went back to Time Out, and in the Advanced screen, changed "Natural break detection method" from "Event Monitor" to "Event Source", then back to "Event Monitor", this fixed the problem! It should now detect idling correctly:

    idle (for 0 secs); Normal due ... not yet idle for at least 30 seconds
    idle (for 1 secs); Normal due ... not yet idle for at least 30 seconds
    idle (for 2 secs); Normal due ... not yet idle for at least 30 seconds

Note that perhaps on the same screen (Advanced), you'll have to adjust the "Natural break active threshold" as well, mine is set to 30 seconds. After the problem is fixed, be sure to disable "Output scheduler logging" as well.

2023-04-04 Kafka introduction tip

If you need an introduction to Kafka, here's a very nice YouTube video on the subject: https://www.youtube.com/watch?v=Ch5VhJzaoaI

Note that it's 4 years old, and I'm not sure how fast Kafka moves.

2023-03-28 Contacts app macOS sorting

The Contacts app (the app previously known as Address Book) will sort by default on last name. If you prefer sorting on first name, and you're a command-line oriented person like me, you want to set your sorting preference from a script. Here's how:

    defaults write com.apple.AddressBook ABNameSortingFormat -string "sortingFirstName sortingLastName"

2023-02-22 Unselectable picker in SwiftUI

Today I spent too much time looking at a bit of code that wasn't working. Here's the problem: the following picker uses a struct to both display values, as well as save the selection. Only problem is; it doesn't work. It displays correctly, but you can't select it; essentially it's read-only.

    struct UnselectablePicker: View {
        struct Language: Identifiable, Hashable  {
            var title: String
            var id: String
        }
        
        var languages: [Language] = [
            Language(title: "English", id: "en-US"),
            Language(title: "German", id: "de-DE"),
            Language(title: "Korean", id: "ko-KR"),
            Language(title: "Dutch", id: "nl-NL")
        ]
        @State private var selectedLanguage = UnselectablePicker.Language(title: "German", id: "de-DE")
        
        var body: some View {
            Picker(selection: $selectedLanguage, label: Text("Front Description")) {
                ForEach(self.languages) {
                    Text($0.title)
                }
            }.pickerStyle(.segmented)
        }
    }

Did you spot it? The problem is in the ForEach. The picker works with the following correction:

    ForEach(self.languages, id: \.self) {
        // ...
    }

2023-01-24 Moving server

Today, I'm moving this website to a new server with a new Debian version. This may mean some interruptions.

Update: the move was a success. The new provider is AlphaVPS and I hope I'll be set for a couple of years.

https://alphavps.com/