Skip to content

Commit

Permalink
feat: theme: support auto choose dark mode
Browse files Browse the repository at this point in the history
Now wiliwili boot use script, please see:
xfangfang/wiliwili#177
xfangfang/wiliwili#181
  • Loading branch information
yuioto committed Aug 12, 2023
1 parent d318220 commit e6fb90e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ pkgbase = wiliwili-git
pkgrel = 1
url = https://github.com/xfangfang/wiliwili
arch = x86_64
arch = i386
arch = aarch64
arch = armv7h
arch = riscv64
arch = loong64
license = GPL3
makedepends = git
makedepends = cmake
Expand All @@ -14,6 +19,8 @@ pkgbase = wiliwili-git
conflicts = wiliwili
conflicts = wiliwili-bin
source = wiliwili::git+https://github.com/xfangfang/wiliwili.git
source = wiliwili.sh
sha256sums = SKIP
sha256sums = 82567c5b14b818d3b628c43f89ae85bc4f60eac22241933379a97318fdebb240

pkgname = wiliwili-git
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
!PKGBUILD
!.SRCINFO
!.gitignore

!wiliwili.sh
10 changes: 8 additions & 2 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ makedepends=('git' 'cmake' 'gcc' 'libwebp')

# options("name")

source=("${_pkg}::git+$url.git")
sha256sums=('SKIP')
source=("${_pkg}::git+$url.git"
"${_pkg}.sh")
sha256sums=('SKIP'
'82567c5b14b818d3b628c43f89ae85bc4f60eac22241933379a97318fdebb240')

pkgver() {
cd "$_pkg"
Expand Down Expand Up @@ -61,6 +63,10 @@ package() {
# main
DESTDIR="${pkgdir}" cmake --install "build"

# booting auto choose dark theme use gdbus.
mv ${pkgdir}/usr/bin/${_pkg} ${pkgdir}/usr/share/${_pkg}/
install -Dm755 "${_pkg}.sh" ${pkgdir}/usr/bin/${_pkg}

# Now cmake will copy this files.
# cp -dr --no-preserve=ownership "build/resources/" "$pkgdir/usr/share/$_pkg/"
# install -Dm755 "$_pkg/scripts/linux/cn.xfangfang.wiliwili.desktop" -t "$pkgdir/usr/share/applications/"
Expand Down
39 changes: 39 additions & 0 deletions wiliwili.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/env bash
#
# org.freedesktop.appearance color-scheme
#
# Indicates the system's preferred color scheme.
# Supported values are:
#
# 0: No preference
# 1: Prefer dark appearance
# 2: Prefer light appearance
#
# Unknown values should be treated as 0 (no preference).

wiliwili_path=/usr/share/wiliwili/wiliwili

scheme=$(
gdbus call --session --timeout=1000 \
--dest=org.freedesktop.portal.Desktop \
--object-path /org/freedesktop/portal/desktop \
--method org.freedesktop.portal.Settings.Read org.freedesktop.appearance color-scheme
)

wiliwili_boot_dark () {
BOREALIS_THEME=DARK $wiliwili_path
}

wiliwili_boot_light () {
BOREALIS_THEME=LIGHT $wiliwili_path
}

wiliwili_boot_default () {
wiliwili_boot_light
}

case $scheme in
( '(<<uint32 1>>,)' ) wiliwili_boot_dark;;
( '(<<uint32 2>>,)' ) wiliwili_boot_light;;
( * ) wiliwili_boot_default;;
esac

0 comments on commit e6fb90e

Please sign in to comment.