Giter Site home page Giter Site logo

pdubs's Introduction

pdubsbuffalo

๐Ÿฆฌ pdubs

A simple command-line utility to return macos window information for a given pid.

macos: 11+ swift: 5.5+

If a given pid does not have an associated window, then it will check all of its ancestors. The window information for the first pid that is associated will be returned. The window information is a list in JSON format.

You may supply one optional parameter providing the pid. If no parameter is provided, then it will search for the current processes pid.

๐Ÿค” Motivation

I wanted an easy way to get the window ID of my current process so that I could take a screenshot from the command-line with screencapture.

screenshot example

win=$(./pdubs | jq .[0].kCGWindowNumber); screencapture -l"$win" pdubs.png

pdubs

๐Ÿ“ฆ Installation

Download the binary for your system

curl --silent --fail --location --output pdubs.tar.gz https://github.com/mikesmithgh/pdubs/releases/latest/download/pdubs.tar.gz
curl --silent --fail --location --output pdubs.tar.gz.sha256 https://github.com/mikesmithgh/pdubs/releases/latest/download/pdubs.tar.gz.sha256
if shasum -c pdubs.tar.gz.sha256; then 
  tar -xvf pdubs.tar.gz 
else
  rm pdubs.tar.gz
fi

Move the binary pdubs to the desired location and place on your $PATH

For example,

mv pdubs ~/bin

๐Ÿ‘ฉโ€๐Ÿ’ป Usage examples

current process

./pdubs
[
  {
    "kCGWindowName" : "./pdubs",
    "kCGWindowStoreType" : 1,
    "kCGWindowOwnerName" : "kitty",
    "kCGWindowAlpha" : 1,
    "kCGWindowSharingState" : 1,
    "kCGWindowBounds" : {
      "X" : 3440,
      "Height" : 1055,
      "Y" : 385,
      "Width" : 1920
    },
    "kCGWindowIsOnscreen" : true,
    "kCGWindowOwnerPID" : 57175,
    "kCGWindowNumber" : 9382,
    "kCGWindowMemoryUsage" : 2288,
    "kCGWindowLayer" : 0
  },
  {
    "kCGWindowStoreType" : 1,
    "kCGWindowName" : "vi README.md ",
    "kCGWindowLayer" : 0,
    "kCGWindowOwnerName" : "kitty",
    "kCGWindowOwnerPID" : 57175,
    "kCGWindowMemoryUsage" : 2288,
    "kCGWindowNumber" : 9432,
    "kCGWindowSharingState" : 1,
    "kCGWindowIsOnscreen" : true,
    "kCGWindowAlpha" : 1,
    "kCGWindowBounds" : {
      "X" : 1720,
      "Height" : 1415,
      "Y" : 25,
      "Width" : 1720
    }
  }
]

target process

./pdubs 62556
[
  {
    "kCGWindowStoreType" : 1,
    "kCGWindowNumber" : 9422,
    "kCGWindowAlpha" : 1,
    "kCGWindowBounds" : {
      "X" : 0,
      "Height" : 1415,
      "Y" : 25,
      "Width" : 1720
    },
    "kCGWindowMemoryUsage" : 2288,
    "kCGWindowOwnerPID" : 62553,
    "kCGWindowLayer" : 0,
    "kCGWindowSharingState" : 1,
    "kCGWindowName" : "-bash",
    "kCGWindowIsOnscreen" : true,
    "kCGWindowOwnerName" : "iTerm2"
  }
]

๐Ÿ”จ Swift commands

debug build

swift build

release build

swift build -c release --arch arm64 --arch x86_64
cd .build/apple/Products/Release || exit 1
tar -czvf pdubs.tar.gz pdubs
shasum --algorithm 256 pdubs.tar.gz | tee pdubs.tar.gz.sha256

run

swift run

๐ŸŽ Supported OS versions

  • macOS 13 Ventura
  • macOS 12 Monterey
  • macOS 11 Big Sur

๐Ÿ•ต๏ธ Troubleshooting

Developer cannot be verified warning

"pdubs" cannot be opened because the developer cannot be verified.

If you receive the warning message while trying to execute pdubs, this is most likely because you manually downloaded the file from the release page. Depending on your download method, Apple will quarantine an app if it is not by an identified developer. I do not have an Apple developer account which is why you will see this warning.

Before removing the app from quarantine, please verify the checksum has not been changed with the shasum command. If this fails, then delete and download pdubs from the release page.

shasum -c pdubs.tar.gz.sha256

You can manually resolves the quarantine by control-clicking and opening the application from Finder or via the following command.

xattr -d com.apple.quarantine pdubs

See What should I do about com.apple.quarantine? for additional information.

pdubs's People

Contributors

mikesmithgh avatar semantic-release-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.