Skip to content

Commit

Permalink
V17: Add theme and background picture follow GNOME Night Light Mode.
Browse files Browse the repository at this point in the history
Refactor code.

Signed-off-by: Hollow Man <[email protected]>
  • Loading branch information
HollowMan6 committed Apr 21, 2021
1 parent 8aa6cbe commit f6c5f21
Show file tree
Hide file tree
Showing 13 changed files with 617 additions and 317 deletions.
52 changes: 47 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

(English version is down below)

### 注意:如果后期无重大 BUG 的话,v15 将是支持 GNOME 3.38 的最后一个版本
### 注意:如果后期无重大 BUG 的话,v17 将是支持 GNOME 3.38 的最后一个版本

在 GNOME Shell 中更改 IBus 的候选框方向、shell 主题、背景图片、字体和输入法默认语言
在 GNOME Shell 中更改 IBus 的候选框方向、字体、输入法默认语言,主题、背景图片跟随 GNOME 夜灯模式自动切换

![demo](img/demo.png)

Expand All @@ -46,14 +46,20 @@ cd Customize-IBus && make install

目前该扩展支持导入该工具生成的样式表。另外还支持[IBus-Theme-Hub](https://github.com/HollowMan6/IBus-Theme-Hub)中提供的 IBus 主题样式表文件。

当浅色主题和深色主题同时开启时,扩展将会自动跟随 GNOME 夜灯模式,关闭时使用浅色主题,开启时使用深色主题。

当浅色主题和深色主题只有一个被开启时,扩展将会始终使用那个开启的主题。

**注:** 如你的 IBus 样式表在应用后作出了更改,请关闭并重新开启对应`自定义主题`来使其生效。

### IBus Tweaker 中的主题

IBus Tweaker 中提供的主题已经被我制作成为 IBus 主题样式表合集[仿微软 Microsoft](https://github.com/HollowMan6/IBus-Theme-Hub/tree/main/%E4%BB%BF%E5%BE%AE%E8%BD%AFMicrosoft),欢迎下载使用!

### _提示:_

1. 推荐使用 X11。如果你在 Wayland 中更改 IBus 主题,你的当前所有工作都将会丢失,因为 Wayland 下只支持通过重新登陆来重启 GNOME-shell。
2. 在 Fedora 33 和 Ubuntu 20.04, GNOME-shell 3.38 中(v3,v5,v9,v11,v14,v15)通过了测试。
2. 在 Fedora 33 和 Ubuntu 20.04, GNOME-shell 3.38 中(v3,v5,v9,v11,v14,v15,v17)通过了测试。
3. 对于那些不使用 GNOME 而是使用如 KDE,XFCE 等桌面环境的用户,更改 IBus GTK 主题也请使用我的另外一个项目[IBus-Theme](https://github.com/HollowMan6/IBus-Theme)

## 更改 IBus 背景图片的实现
Expand All @@ -70,6 +76,12 @@ background-size: cover;

进一步结合[ibus-font-setting](https://extensions.gnome.org/extension/1121/ibus-font-setting/)和[background-logo](https://pagure.io/background-logo-extension),参考 GNOME-Shell 源代码中`candidate-popup-content`样式[对应组件](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/ibusCandidatePopup.js#L154),并对其修改样式实现不重启 GNOME-Shell 进行 IBus 背景图片的修改。

当浅色背景和深色背景同时开启时,扩展将会自动跟随 GNOME 夜灯模式,关闭时使用浅色背景,开启时使用深色背景。

当浅色背景和深色背景只有一个被开启时,扩展将会始终使用那个开启的背景。

**注:** 请确保背景图片始终可以访问,如你的图片存放在可移动设备,系统默认不挂载,每次手动挂载后请关闭并重新开启对应`自定义背景`来使其生效。

## 备忘

- [x] 从[ibus-tweaker](https://github.com/tuberry/ibus-tweaker)中导入,去除与 IBus 无关功能。
Expand All @@ -79,6 +91,8 @@ background-size: cover;
- [x] V14: 将从 GNOME-Shell 主题提取 IBus 样式功能剥离,使用 Python 下 CSS 解析器而并非正则表达式实现功能,生成额外 IBus 样式表供用户修改测试使用。
- [x] V14: 本扩展改为接受用户提供的 IBus 样式表进行样式的应用。
- [x] V15: 修改主题加载逻辑,免去每次更换主题都要重启 GNOME-Shell。
- [x] V17: 增加浅色和深色背景与主题,跟随 GNOME 夜灯模式自动切换。
- [x] V17: 重构代码。

## 致谢

Expand All @@ -92,7 +106,7 @@ _该项目是谷歌编程之夏 (GSoC) 2021 于[OpenSUSE](https://github.com/ope

### Note: If no severe bug was found later, v15 will be the last version that support GNOME 3.38.

Customize IBus for orientation, shell theme, background picture, font and ascii mode auto-switch.
Customize IBus for orientation, font, ascii mode auto-switch; theme and background picture follow GNOME Night Light Mode.

![demo](img/demo-en.png)

Expand All @@ -117,16 +131,42 @@ This function has been separated, generating IBus theme stylesheet has been move

Now this extension supports importing stylesheet generated by this tool. In addition it also supports the IBus theme stylesheets provided by [IBus-Theme-Hub](https://github.com/HollowMan6/IBus-Theme-Hub).

When light theme and dark theme are turned on at the same time, the extension will automatically follow GNOME Night Light mode, use light theme when off, and use dark theme when on.

When only one of the light theme and dark theme is turned on, the extension will always use the theme that is turned on.

**Note:** If your IBus style sheet has changed after application, please close and reopen the corresponding `custom IME theme` to make it effective.

### Themes in IBus Tweaker

Themes in IBus Tweaker have been converted by me as IBus theme stylesheets collection [仿微软 Microsoft](https://github.com/HollowMan6/IBus-Theme-Hub/tree/main/%E4%BB%BF%E5%BE%AE%E8%BD%AFMicrosoft), you are welcomed to use it!

### _NOTE:_

1. Recommend to use X11. If you change IME theme under Wayland, all your current work may be lost (Since Wayland only support relogin to restart the GNOME-shell).
2. Tested on Fedora 33 and Ubuntu 20.04, GNOME-shell 3.38(v3, v5, v9, v11, v14, v15).
2. Tested on Fedora 33 and Ubuntu 20.04, GNOME-shell 3.38(v3, v5, v9, v11, v14, v15, v17).
3. For users who don't use GNOME but other desktop environments like KDE, XFCE, etc., please also use another project of mine [IBus-Theme](https://github.com/HollowMan6/IBus-Theme) to use a different GTK theme for IBus.

## Realization of Modifying IBus Background Picture

During [fixing Unity8-Wood theme and add support for IBus Backgound](https://github.com/openSUSE/mentoring/issues/158#issuecomment-813837436), I found that if I add the following style for class `.candidate-popup-content`:

```css
background: url("assets/bg.png");
background-repeat: no-repeat;
background-size: cover;
```

I can modify the background picture.

Further combining [ibus-font-setting](https://extensions.gnome.org/extension/1121/ibus-font-setting/) and [background-logo](https://pagure.io/background-logo-extension), referring to GNOME-Shell's source code, I found the [corresponding widget](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/ibusCandidatePopup.js#L154) for class `candidate-popup-content`, and modified the style to realize modifying IBus background picture without restarting GNOME-Shell.

When light background and dark background are turned on at the same time, the extension will automatically follow GNOME Night Light mode, use light background when off, and use dark background when on.

When only one of the light background and dark background is turned on, the extension will always use the background that is turned on.

**Note:** If your IBus style sheet has changed after application, please close and reopen the corresponding `custom IME background` to make it effective.

## To-do

- [x] Import from [ibus-tweaker](https://github.com/tuberry/ibus-tweaker) and remove features unrelated to IBus.
Expand All @@ -136,6 +176,8 @@ Themes in IBus Tweaker have been converted by me as IBus theme stylesheets colle
- [x] V14: Strip the current function of extracting IBus style from Gnome shell theme, implement using CSS parser libraries in Python instead of regular expression. Additional IBus style sheets are generated for users to modify and test.
- [x] V14: Modify this extension to accept IBus style sheets provided by users for style application.
- [x] V15: Modify theme load logic so that now we don't need to reload GNOME-Shell to change IBus themes.
- [x] V17: Add theme and background picture follow GNOME Night Light Mode.
- [x] V17: Refactor code.

## Acknowledgements

Expand Down
Loading

0 comments on commit f6c5f21

Please sign in to comment.