Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/themes-screenshot-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ jobs:
fi
done

- name: Generate theme list Markdown page
run: |
python3 tools/theme-preview-generator.py

- name: Commit theme previews
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[GitHub Actions Bot] Update theme previews"
file_pattern: 'res/themes/*/preview.png'
file_pattern: 'res/themes/*/preview.png res/themes/themes.md'
status_options: '--untracked-files=no'

- name: Run if changes have been detected
Expand Down
12 changes: 12 additions & 0 deletions res/themes/themes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--- This file is generated automatically by GitHub Actions, do not edit it! --->

# Turing Smart Screen themes

[3.5" themes](#35-themes)
[5" themes](#5-themes)

## 3.5" themes
<table><td>3.5inchTheme2<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/3.5inchTheme2/preview.png" width="150"/></td><td>bash-dark-green<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/bash-dark-green/preview.png" width="150"/></td><td>bash-dark-green-gpu<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/bash-dark-green-gpu/preview.png" width="150"/></td><td>BigClock<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/BigClock/preview.png" width="150"/></td><td>Cyberpunk<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/Cyberpunk/preview.png" width="150"/></td></table><table><td>Cyberpunk-net<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/Cyberpunk-net/preview.png" width="150"/></td><td>Landscape6Grid<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/Landscape6Grid/preview.png" width="150"/></td><td>LandscapeEarth<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/LandscapeEarth/preview.png" width="150"/></td><td>LandscapeMagicBlue<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/LandscapeMagicBlue/preview.png" width="150"/></td><td>Terminal<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/Terminal/preview.png" width="150"/></td></table><table></table>

## 5" themes
<table><td>5inchTheme2<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/5inchTheme2/preview.png" width="150"/></td><td>CyanTheme<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/CyanTheme/preview.png" width="150"/></td><td>DragonBall5inch<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/DragonBall5inch/preview.png" width="150"/></td><td>Landscape15Grid<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/Landscape15Grid/preview.png" width="150"/></td><td>NZXT_B<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/NZXT_B/preview.png" width="150"/></td></table><table><td>NZXT_BLUR<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/NZXT_BLUR/preview.png" width="150"/></td><td>NZXT_C<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/NZXT_C/preview.png" width="150"/></td><td>NZXT_color<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/NZXT_color/preview.png" width="150"/></td><td>NZXT_dynamic<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/NZXT_dynamic/preview.png" width="150"/></td><td>PurpleTheme<img src="https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/PurpleTheme/preview.png" width="150"/></td></table><table></table>
78 changes: 78 additions & 0 deletions tools/theme-preview-generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env python
# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang
# https://github.com/mathoudebine/turing-smart-screen-python/

# Copyright (C) 2021-2023 Matthieu Houdebine (mathoudebine)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# theme-preview-generator.py: Run by GitHub actions on new commits, to generate a MarkDown page containing themes list
# and their associated preview

import os
import yaml


def get_themes(display_size: str):
themes = []
directory = 'res/themes/'
for filename in os.listdir('res/themes'):
dir = os.path.join(directory, filename)
# checking if it is a directory
if os.path.isdir(dir):
# Check if a theme.yaml file exists
theme = os.path.join(dir, 'theme.yaml')
if os.path.isfile(theme):
# Get display size from theme.yaml
with open(theme, "rt", encoding='utf8') as stream:
theme_data = yaml.safe_load(stream)
if theme_data['display'].get("DISPLAY_SIZE", '3.5"') == display_size:
themes.append(filename)
return sorted(themes, key=str.casefold)


if __name__ == "__main__":
themes3inch = get_themes('3.5"')
themes5inch = get_themes('5"')

with open("res/themes/themes.md", "w", encoding='utf-8') as file:
file.write("<!--- This file is generated automatically by GitHub Actions, do not edit it! --->\n")
file.write("\n")
file.write("# Turing Smart Screen themes\n")
file.write("\n")
file.write("[3.5\" themes](#35-themes)\n")
file.write("[5\" themes](#5-themes)\n")

file.write("\n## 3.5\" themes\n")
file.write("<table>")
i = 0
for theme in themes3inch:
file.write(f"<td>{theme}<img src=\"https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/{theme}/preview.png\" width=\"150\"/></td>")
i = i + 1
if i >= 5:
file.write("</table><table>")
i = 0
file.write("</table>\n")

file.write("\n## 5\" themes\n")
file.write("<table>")
i = 0
for theme in themes5inch:
file.write(f"<td>{theme}<img src=\"https://raw.githubusercontent.com/mathoudebine/turing-smart-screen-python/main/res/themes/{theme}/preview.png\" width=\"150\"/></td>")
i = i + 1
if i >= 5:
file.write("</table><table>")
i = 0
file.write("</table>\n")