Skip to content

Commit

Permalink
[add] bilibili poster
Browse files Browse the repository at this point in the history
  • Loading branch information
AIboy996 committed Jun 9, 2024
1 parent a4eac21 commit f3adb4b
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 14 deletions.
Binary file added docs/Note/Mac/assets/2024-06-10-01-27-47.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Note/Mac/assets/2024-06-10.mov
Binary file not shown.
61 changes: 52 additions & 9 deletions docs/Note/Mac/sketchybar.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,43 @@ tags:
---

# sketchybar+yabai
> 相关的配置文件保存在我的[dotfiles仓库](https://github.com/AIboy996/dotfiles)
> 相关的配置文件保存在我的[dotfiles仓库](https://github.com/AIboy996/dotfiles)主要参照FelixKratz的[dotfiles](https://github.com/FelixKratz/dotfiles)
使用sketchybar+yabai来替代mac原生的菜单栏:

![type:video](./assets/2024-05-27.mov)

主要功能:

- Apple Logo(可以弹出几个菜单)
- 显示各个Desktop Spaces在运行的窗口(使用yabai实现)
- 点击的时候切换到对应的Space(使用osacript实现)
- 显示当前激活的窗口
- 显示当前激活的窗口标题
- 显示其他自定义内容
- 微信、QQ通知
- 电池
- 日期

我自己修改的功能:

- [桌面切换](#_1):点击的时候切换到对应的Space(使用osacript实现)
- FelixKratz是使用yabai实现Space切换。
- [实时监听窗口变化](#_5):有窗口变动时自动更新Desktop Spaces的内容(使用sketchybar自带的事件`space_windows_change`实现)
- FelixKratz的模版无此功能,只有切换Space的时候才会更新。

软件的安装、启动没啥好说的。跟着官方的教程走就行了。

安装完之后可以设置Mac内置的菜单栏在桌面视图自动隐藏:
![](assets/2024-05-27-14-54-32.png)

## 桌面切换(yabai)
## 桌面切换

### yabai
值得一提的是,yabai虽然功能很强大,但是想要实现**切换Desktop Space**的功能需要配置Scripts Addition。

而想要开启这个SA功能个首先需要关闭MacOS的System Integrity Protection,然后才可以:
> yabai uses the macOS Mach APIs to **inject code** into Dock.app; this requires elevated (root) privileges. You can configure your user to execute yabai --load-sa as the root user without having to enter a password. To do this, we add a new configuration entry that is loaded by /etc/sudoers.
看起来就是一个非常危险的操作,我不太愿意这么干。

## 桌面切换(osascript)
所以我寻找了一个替代方案:osascript,这是Mac自带的脚本工具。
看起来就是一个非常危险的操作,我不太愿意这么干。所以我寻找了一个替代方案:osascript,这是Mac自带的脚本工具。

> osascript – execute OSA scripts (AppleScript, JavaScript, etc.)
Expand Down Expand Up @@ -82,4 +88,41 @@ osascript -e "tell application \"System Events\" to key code $((SID+17)) using c

> `key code 18`对应数字键1,更多对应关系如下:
![](assets/2024-05-27-14-46-33.png)
![](assets/2024-05-27-14-46-33.png)

## 实时监听窗口变化

### 效果
![type:video](assets/2024-06-10.mov)
### 实现方法
根据官方文档sketchybar会时刻检查窗口的情况,如果有新增或者减少都会触发`space_windows_change`事件。所以我们只需要订阅这个事件即可:

![](assets/2024-06-10-01-27-47.png)


主要修改的代码如下:
```bash hl_lines="9" title="items/spaces.sh"
spaces=()
for i in "${!SPACE_ICONS[@]}"; do
sid=$(($i + 1))
space=(
...
)
sketchybar --add space space.$sid left \
--set space.$sid "${space[@]}" \
--subscribe space.$sid mouse.clicked space_windows_change
done
```

```bash hl_lines="4-6" title="plugins/space.sh"
case "$SENDER" in
"mouse.clicked") mouse_clicked
;;
"space_windows_change")
# 手动触发windows_on_spaces事件,即可实现图标的更新
sketchybar --trigger windows_on_spaces
;;
*) update
;;
esac
```
Binary file added docs/Project/assets/2024-06-10-01-57-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions docs/Project/bilibili_poster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
tags:
- PyPJ
- 前端
- 开源项目
---

# bilibili_poster
Live at <https://bilibili.yangz.site>

<figure markdown>

[![AIboy996/bilibili_poster - GitHub](https://gh-card.dev/repos/AIboy996/bilibili_poster.svg?fullname=)](https://github.com/AIboy996/bilibili_poster)

</figure>


<figure markdown>

![](assets/2024-06-10-01-57-20.png)

</figure>

!!! success
已完成,每日更新中。
1 change: 1 addition & 0 deletions docs/Project/plt-gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tags:
- 开源项目
---
# plt-gallery
Live at <https://plt.yangz.site>

<figure markdown>
[![AIboy996/plt-gallery - GitHub](https://gh-card.dev/repos/AIboy996/plt-gallery.svg?fullname=)](https://github.com/AIboy996/plt-gallery)
Expand Down
8 changes: 3 additions & 5 deletions docs/Project/pymd.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ tags:

# pymd

Live at <https://aiboy996.github.io/pymd/>

<figure markdown>
[![AIboy996/pymd - GitHub](https://gh-card.dev/repos/AIboy996/pymd.svg?fullname=)](https://github.com/AIboy996/pymd)
</figure>

!!! success
基础语法实现完成,等待进一步完善。

<hr>

渲染效果预览:<https://aiboy996.github.io/pymd/>
基础语法实现完成,等待进一步完善。
1 change: 1 addition & 0 deletions nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ nav:
- Project/npnn.md
- Project/pymd.md
- Project/plt-gallery.md
- Project/bilibili_poster.md
- Project/high_school_math.md
- Project/mkdocs-ai-summary.md
- Project/AirPrint-with-Python.md
Expand Down

0 comments on commit f3adb4b

Please sign in to comment.