Skip to content

Instantly share code, notes, and snippets.

View usagimaru's full-sized avatar
🐰

usagimaru usagimaru

🐰
View GitHub Profile
@usagimaru
usagimaru / DividerOfSplitView.swift
Last active March 5, 2024 19:15
Get NSSplitView’s divider view from a subclass (customize divider height and color)
import Cocoa
class SplitView: NSSplitView {
override var dividerThickness: CGFloat {
50
}
override var dividerColor: NSColor {
NSColor.red
@usagimaru
usagimaru / shut_up_chrome.md
Last active November 17, 2023 11:37
How to prohibit Google Chrome from adding itself to Login Items and notification banners on macOS.

Prohibit Google Chrome from adding itself to Login Items on macOS

TL;DR

Google Chrome behaves badly, registering itself in Login Items on every startup and trying to stay resident on the system. macOS Ventura and later systems have a system that notifies you when something is registered in Login Items, and when the condition is met, a notification banner appears. These appears every time we start up Google Chrome. This is the nightmare.

How macOS agents work

Login Items in macOS are based on a mechanism called LaunchAgents or LaunchDaemons. By registering information on programs to be launched at system startup in a plist file, background processes can be driven.

@usagimaru
usagimaru / add_xcode_envs.sh
Last active October 29, 2023 03:24
A shell script to add some environment variables to Xcode's scheme to suppress useless console outputs. (e.g. os_log messages)
#!/bin/sh
function printHelp () {
printBlueBold "===================="
printBlueBold "Add useful environment variables to a scheme of Xcode."
printBlueBold "Usage:"
printBlueBold " %% THIS_SCRIPT.sh AnyProject.xcodeproj"
printBlueBold "===================="
}
@usagimaru
usagimaru / gist:36863710d1f8c8edd4a4c5051b40118a
Created September 14, 2023 22:50
The location of the recents data of macOS apps

Mac app's "recents" data is stored at:

~/Library/Application Support/com.apple.sharedfilelist
@usagimaru
usagimaru / customize_sketch_keyboard_shortcuts.md
Last active August 24, 2023 10:56
Customize Sketch.app’s Open and Save keyboard shortcuts.

Scripts

# Print any keyequivalent definitions
PlistBuddy -c "print NSUserKeyEquivalents" ~/Library/Preferences/com.bohemiancoding.sketch3.plist
# Set keyequivalent of 'Open…' as '^⌘O'
PlistBuddy -c "set NSUserKeyEquivalents:'Open…' '@^o'" ~/Library/Preferences/com.bohemiancoding.sketch3.plist
@usagimaru
usagimaru / disable_any_keyboard_shortcuts_on_macos.md
Last active August 24, 2023 10:31
Disable any keyboard shortcuts of the specific app on macOS.

Disable any keyboard shortcuts of the specific app on macOS

Shell Script

#!/bin/sh

defaults write com.bohemiancoding.sketch3 NSUserKeyEquivalents '{
"Show Prototyping"=" ";
"Show Slices"=" ";
@usagimaru
usagimaru / createdmg_shortcut.sh
Last active February 5, 2024 03:09
My `create-dmg` script for macOS
#!/bin/sh
in_dir_name=$1
the_app_name=$2
out_dmg_name=$3
bg_image=$4
## https://github.com/create-dmg/create-dmg
create-dmg \
@usagimaru
usagimaru / accessibilityDisplayShouldShowToolbarButtonShapes.swift
Last active February 25, 2024 20:53
Get the "Show toolbar button shapes" option flag of the macOS system accessibility settings (using private API)
// "accessibilityDisplayShouldShowToolbarButtonShapes" changes will call this notification.
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.accessibilityDisplayOptionsDidChangeNotification,
object: NSWorkspace.shared,
queue: nil) { notif in
// Get the current flag
// The property of NSSWorkspaceAccessibilityDisplay "accessoryDisplayShouldShowToolbarButtonShapes" is private on macOS 13.
let flag = NSWorkspace.shared.value(forKey: "accessibilityDisplayShouldShowToolbarButtonShapes")!
print("\(flag)")
@usagimaru
usagimaru / denies_for_apple_dev.txt
Last active August 24, 2023 09:27
uBlacklist list for Apple dev
*://learn.microsoft.com/*/dotnet/*
*://learn.microsoft.com/*/xamarin/*
*://learn.microsoft.ex1.https.443.ipv6.yunfu.gov.cn/*
*://www.cnblogs.com/*
*://juejin.cn/*
*://www.oschina.net/*
*://blog.csdn.net/*
*://zhuanlan.zhihu.com/*
*://devliusir.com/*
*://davidleee.com/*
@usagimaru
usagimaru / xcode_delete_key_input_broken.md
Last active June 21, 2023 03:34
XcodeのDelete入力が壊れる

XcodeのDelete入力が壊れる

症状

XcodeのエディタでDeleteキーの入力が壊れてしまう、backspace不可視文字が入力される、カーソルが正しく機能しなくなる。

原因

何かの拍子にXcodeのキーバインディング設定 Delete Backward に割り当てられた設定が壊れた可能性がある。