1

I would like to know how to find what apps are minimized in the dock but through the terminal?

The idea is to make a script that pauses minimized apps in order to reduce memory usage but the first step is to get a list of these.

Is there any way to determine what apps are minimized?

1 Answer 1

2

You would probably need to use AppleScript to discern the status of apps' windows being minimised or not, although you can run this AppleScript from the command line by using the command osascript:

osascript <<OSA
    use application "System Events"

    set _P to a reference to (every process where the ¬
        value of attribute "AXMinimized" of ¬
        every window contains true)

    set _Q to a reference to (every process where the ¬
        value of attribute "AXMinimized" of ¬
        every window contains true and the ¬
        value of attribute "AXMinimized" of ¬
        every window does not contain false)

    -- every app that has at least one minimised window
    name of _P

    -- every app that has all windows minimised
    # name of _Q
OSA

As you can see, I've defined two variables, _P and _Q, that both contains apps with minimised windows, but discriminate differently based on whether every window of the app or just some of the windows of the app are minimised.

I've commented out the last line of AppleScript, name of _Q by putting a # at the start. This means the script will ignore this line, allowing it to return the value of the line above it, which is name of _P. If you remove the #, the script will return the value of name of _Q.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .