### Install BetterAndBetter via Homebrew Cask Source: https://context7.com/songhao/betterandbetter/llms.txt This command installs BetterAndBetter using Homebrew Cask. Ensure you have Homebrew installed and have tapped the necessary third-party repository. This command also shows the current Cask version and minimum system requirement. ```bash # 通过 Homebrew Cask 安装(需先添加第三方 tap) brew tap suliveevil/BetterAndBetter brew install --cask betterandbetter # 当前 Cask 版本:v1.6.43,最低系统要求:macOS Sierra (10.12)+ ``` -------------------------------- ### Get Current System UI Element using GUI Scripting Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript uses GUI scripting to list all UI elements in the menu bar area of SystemUIServer. This is useful for debugging or writing more complex GUI automation scripts. ```applescript -- 示例 2:用 GUI 脚本获取当前系统 UI 元素(调试/自动化用) tell application "System Events" tell process "SystemUIServer" -- 列出菜单栏区域的所有 UI 元素,用于编写更复杂的 GUI 自动化脚本 entire contents end tell end tell ``` -------------------------------- ### Search Selected Text on Baidu via Touchpad Gesture Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript is designed to be triggered by a touchpad gesture in BetterAndBetter. It searches the selected text on Baidu using Google Chrome. Ensure Google Chrome is installed and configured for this script to function correctly. ```applescript -- 示例:通过触摸板手势触发后,在 BetterAndBetter 脚本模块中执行 -- 将所选文字在百度中搜索(绑定到触摸板三指右滑手势) set myURL to "https://www.baidu.com/s?wd=SelectedText" tell application "Google Chrome" activate tell window 1 of application "Google Chrome" set myActiveTab to active tab if myURL is not "" then -- 在当前标签页之后新建标签页并打开搜索结果 set myTab to make new tab at after myActiveTab with properties {URL:myURL} end if end tell end tell -- 配置步骤: -- 1. 打开 BetterAndBetter → 触摸模块 -- 2. 点击 "+" 新增规则,选择手势(如三指向右划) -- 3. 动作类型选择 "AppleScript",粘贴上方脚本 -- 4. 保存,此后在任意 App 中用三指右划即触发 Chrome 搜索 ``` -------------------------------- ### Activate Work Apps and Mute Notifications via Scene Mode Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript is intended for use with BetterAndBetter's Scene Mode. When triggered (e.g., by connecting to a specific Wi-Fi network), it activates common work applications like Xcode, Slack, and Terminal, and attempts to disable Do Not Disturb. Ensure the specified applications are installed. ```applescript -- 示例:情景模式触发时执行的 AppleScript——切换到"工作模式" -- 自动打开常用工作 App 并静音通知 -- 打开指定工作应用 tell application "Xcode" to activate tell application "Slack" to activate tell application "Terminal" to activate -- 关闭通知勿扰模式(Do Not Disturb) tell application "System Events" tell process "SystemUIServer" -- 获取菜单栏中的通知中心图标并检查状态 entire contents end tell end tell -- 配置步骤: -- 1. 打开 BetterAndBetter → 情景模式 -- 2. 点击 "+" 新建情景,命名为"工作模式" -- 3. 设置触发条件(如连接到公司 Wi-Fi SSID "CompanyNet") -- 4. 动作中选择 "AppleScript",粘贴上方脚本 -- 5. 下次连接到该 Wi-Fi 时自动执行 ``` -------------------------------- ### Manage BetterAndBetter Configuration Files Source: https://context7.com/songhao/betterandbetter/llms.txt These shell commands demonstrate how to read, back up, and restore BetterAndBetter configuration files using the 'defaults' command and standard file operations. Restart BetterAndBetter after restoring configuration. ```shell -- 示例 3:高级配置文件操作(终端) -- 查看 BetterAndBetter 配置文件(plist 格式) -- $ defaults read com.sunny.BetterAndBetter -- 备份配置 -- $ cp ~/Library/Preferences/com.sunny.BetterAndBetter.plist ~/Desktop/BAB_backup.plist -- 还原配置 -- $ cp ~/Desktop/BAB_backup.plist ~/Library/Preferences/com.sunny.BetterAndBetter.plist -- $ killall BetterAndBetter # 重启使配置生效 ``` -------------------------------- ### Access BetterAndBetter Configuration and Preferences Source: https://context7.com/songhao/betterandbetter/llms.txt These commands show how to locate the BetterAndBetter configuration file and read all current configuration settings using the 'defaults' command. This is useful for understanding and managing application settings. ```bash # 查看配置文件路径 ls ~/Library/Preferences/com.sunny.BetterAndBetter.plist # 使用 defaults 命令读取当前所有配置项 defaults read com.sunny.BetterAndBetter ``` -------------------------------- ### Shell Configuration File Path Source: https://github.com/songhao/betterandbetter/blob/master/readme.md This command displays the path to the BetterAndBetter configuration file. Use this path to locate and edit the application's settings. ```shell echo "$APP_CONFIG_PATH" ``` -------------------------------- ### Create Symbolic Link in Finder using AppleScript Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript creates a symbolic link for the selected file(s) in Finder. It copies the file path to the clipboard and then uses a shell script to create the link in the parent directory. Bind this to a mouse gesture or hotkey. ```applescript -- 示例 1:在 Finder 中为选中文件创建符号链接(绑定到鼠标手势或快捷键) tell application "System Events" tell application "Finder" set theItems to selection -- 获取选中文件的 POSIX 路径 set filePath to (POSIX path of (the selection as alias)) end tell -- 将路径复制到剪切板 set the clipboard to filePath end tell -- 在父目录中创建符号链接 do shell script "path=$(pbpaste); chmod a+x $path; cd ..; ln -s " & filePath & " " & filePath ``` -------------------------------- ### AppleScript for Safari Search Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript opens a new tab in Safari and searches for the selected text on Baidu. Configure this in the Corner Trigger module for a specific corner. ```applescript -- 示例:右下角触发——用 Safari 搜索当前选中文字(在 Safari 中新开标签) set myURL to "https://www.baidu.com/s?wd=SelectedText" tell application "Safari" activate tell window 1 of application "Safari" set myActiveTab to current tab if myURL is not "" then -- 在当前标签之后插入新搜索标签 set myTab to make new tab at after myActiveTab with properties {URL:myURL} end if end tell end tell -- 配置步骤: -- 1. 打开 BetterAndBetter → 边角触发模块 -- 2. 选择屏幕右下角,触发方式选"左键点击" -- 3. 动作类型选 "AppleScript",粘贴上方脚本 -- 4. 此后鼠标移至右下角并左键点击即触发 Safari 搜索 ``` -------------------------------- ### Toggle Menu Bar Auto-Hide via Keyboard Shortcut Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript uses GUI scripting to toggle the 'Automatically hide and show the menu bar' setting in macOS System Preferences. It's designed to be bound to a custom keyboard shortcut within BetterAndBetter. The script checks the current state and performs the toggle only if the menu bar is currently visible. ```applescript -- 示例:为自定义快捷键(如 ⌃⌥⌘M)绑定"切换菜单栏自动隐藏"功能 -- GUI 脚本:切换系统偏好设置中的"自动隐藏和显示菜单栏"选项 tell application "System Preferences" to reveal the ¬ anchor named "main" of ¬ pane id "com.apple.preference.general" tell application "System Events" tell process "System Preferences" tell window "通用" -- 若复选框当前为勾选状态,则取消;否则执行空操作 if checkbox "自动隐藏和显示菜单栏" is true then perform action "AXPress" else do shell script "" end if end tell end tell end tell -- 配置步骤: -- 1. 打开 BetterAndBetter → 键盘模块 -- 2. 点击 "+" 新增规则,录入快捷键 ⌃⌥⌘M -- 3. 动作类型选择 "AppleScript",粘贴上方脚本 -- 4. 保存后,按下该快捷键即可全局切换菜单栏隐藏状态 ``` -------------------------------- ### Close Other Tabs in Safari via Mouse Gesture Source: https://context7.com/songhao/betterandbetter/llms.txt This AppleScript, triggered by a mouse gesture in BetterAndBetter, closes all tabs in the current Safari window except for the active one. It's useful for quickly decluttering your browsing session. Ensure Safari is running when the gesture is performed. ```applescript -- 示例:鼠标右键绘制"↑"手势后,在 Safari 中关闭除当前标签外的所有标签页 activate application "Safari" tell application "Safari" set currentWindow to window 0 set tabCount to count of tabs of currentWindow -- 从末尾向前遍历,跳过当前激活标签 repeat with i from tabCount - 1 to 0 by -1 if index of tab i of currentWindow is not equal to index of current tab of currentWindow then close tab i of currentWindow end if end repeat end tell -- 配置步骤: -- 1. 打开 BetterAndBetter → 鼠标模块 → 按住右键 -- 2. 点击 "+" 新增手势,在画布上绘制向上箭头轨迹 -- 3. 手势相似度设为 80,动作选 "AppleScript",粘贴上方脚本 -- 4. 可选:在应用黑名单中排除不需要此手势的 App ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.