mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
Flatpak build (#4175)
* Initial commit for the builder
* fix wx, use hack to install into /app
* add some workarounds for /usr/local
* fix up rest of paths
* attempt to fix wxwebview undef
* figure out why wxwidgets isnt getting its patches applied
* do "proper" patching of wxwidgets
* Flip the flag
* actually append the /usr/local
* restrict package finding to flatpak only
* Update the destdir stuff for mpfr, gmp
* Transfer over all the _destdir, again
* update patch command for all other plats
* initial ci check
* what even happened
* clear ci image
* I doubt this will do anything
* do cleanup after running each step
* remove build objects for flatpak ci
* compress debug info
* Fix MacOS build
* Try saving space after building deps
* No debug info for now
* Do debug info, use thin static archives
* use BSD flag, not --thin
* try building with lto
* Use release, no debug info
* remove lto
* Revert the last 5 commits
* It might require write perms
* Revert "It might require write perms"
This reverts commit 44cec58a57.
* Import fixes for merge
* remove some patch stuff
* the worst hack!
* remove uneeded patches
* Initial commit for the builder
* note to self, go back to regular wx
* attempt to fix wxwebview undef
* do "proper" patching of wxwidgets
* update patch command for all other plats
* what even happened
* -ldep_name-NOTFOUND is still here
* concat patches
* Build wx with flatpak
* more wx shenatigans
* fix a missing import
* build wx with proper flags
* fix imports and libs
* trigger ci
* try fixing mac and windows ci
* remove duplicate definition of freetype
* curl may not have openssl for a dep
* has openssl been found?
* force building
* build images on apple
* cleanup for review
* cleanup cmake files
---------
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
2
flatpak/.gitignore
vendored
Normal file
2
flatpak/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
builddir
|
||||
.flatpak-builder
|
||||
3
flatpak/README.md
Normal file
3
flatpak/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# OrcaSlicer
|
||||
|
||||
This is basically a copy of [com.bambulab.BambuStudio](https://github.com/flathub/com.bambulab.BambuStudio). As such, same rules apply here as does over there.
|
||||
15
flatpak/entrypoint
Normal file
15
flatpak/entrypoint
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Work-around https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/754
|
||||
grep -q org.freedesktop.Platform.GL.nvidia /.flatpak-info && export WEBKIT_DISABLE_DMABUF_RENDERER=1
|
||||
|
||||
# Work-around https://github.com/bambulab/BambuStudio/issues/3440
|
||||
export LC_ALL=C.UTF-8
|
||||
|
||||
if [ $BAMBU_STUDIO_DARK_THEME == true ]; then
|
||||
export GTK_THEME='Adwaita:dark'
|
||||
# echo "Message: $(date +%T): INFO: using dark theme variant"
|
||||
fi
|
||||
|
||||
exec /app/bin/orca-slicer "$@" &
|
||||
$(/app/bin/set-dark-theme-variant.py) &
|
||||
BIN
flatpak/images/1.png
Normal file
BIN
flatpak/images/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 280 KiB |
BIN
flatpak/images/2.png
Normal file
BIN
flatpak/images/2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 976 KiB |
48
flatpak/io.github.softfever.OrcaSlicer.metainfo.xml
Executable file
48
flatpak/io.github.softfever.OrcaSlicer.metainfo.xml
Executable file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component type="desktop">
|
||||
<id>io.github.softfever.OrcaSlicer</id>
|
||||
<launchable type="desktop-id">io.github.softfever.OrcaSlicer.desktop</launchable>
|
||||
<provides>
|
||||
<id>io.github.softfever.OrcaSlicer.desktop</id>
|
||||
</provides>
|
||||
<name>OrcaSlicer</name>
|
||||
<!-- hehe hadess @ppd
|
||||
... seriously though, thanks -->
|
||||
<summary>Get even more perfect prints!</summary>
|
||||
<developer_name>SoftFever</developer_name>
|
||||
<url type="homepage">https://github.com/SoftFever/OrcaSlicer</url>
|
||||
<url type="help">https://github.com/SoftFever/OrcaSlicer/wiki</url>
|
||||
<url type="bugtracker">https://github.com/SoftFever/OrcaSlicer/issues/</url>
|
||||
<url type="donation">https://ko-fi.com/SoftFever</url>
|
||||
<metadata_license>0BSD</metadata_license>
|
||||
<project_license>AGPL-3.0-only</project_license>
|
||||
<content_rating type="oars-1.1" />
|
||||
<requires>
|
||||
<display_length compare="gt">768</display_length>
|
||||
</requires>
|
||||
<recommends>
|
||||
<control>keyboard</control>
|
||||
<control>pointing</control>
|
||||
</recommends>
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<image>https://raw.githubusercontent.com/powpingdone/com.github.softfever.orcaslicer/master/images/1.png</image>
|
||||
<caption>A model ready to be sliced on a buildplate.</caption>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<image>https://raw.githubusercontent.com/powpingdone/com.github.softfever.orcaslicer/master/images/2.png
|
||||
</image>
|
||||
<caption>A calibration test ready to be printed out.</caption>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
<description>
|
||||
<p>A 3D printer slicer forked from Bambu Studio, PrusaSlicer, and SuperSlicer with many more printer profiles, helpful calibration prints, and many more features to get your 3D printer printing perfectly!</p>
|
||||
</description>
|
||||
<branding>
|
||||
<color type="primary" scheme_preference="light">#009688</color>
|
||||
</branding>
|
||||
<releases>
|
||||
<release version="2.0.0-951fc8e" date="2024-01-30"> <url>https://github.com/SoftFever/OrcaSlicer/commit/951fc8e98a0d5ca0ccb254315646ce7889a44836</url>
|
||||
</release>
|
||||
</releases>
|
||||
</component>
|
||||
344
flatpak/io.github.softfever.OrcaSlicer.yml
Executable file
344
flatpak/io.github.softfever.OrcaSlicer.yml
Executable file
@@ -0,0 +1,344 @@
|
||||
app-id: io.github.softfever.OrcaSlicer
|
||||
runtime: org.gnome.Platform
|
||||
runtime-version: "45"
|
||||
sdk: org.gnome.Sdk
|
||||
command: entrypoint
|
||||
separate-locales: true
|
||||
rename-icon: OrcaSlicer
|
||||
finish-args:
|
||||
- --share=ipc
|
||||
- --socket=x11
|
||||
- --share=network
|
||||
- --device=all
|
||||
- --filesystem=home
|
||||
- --filesystem=xdg-run/gvfs
|
||||
- --filesystem=/run/media
|
||||
- --filesystem=/media
|
||||
# Allow OrcaSlicer to talk to other instances
|
||||
- --talk-name=io.github.softfever.OrcaSlicer.InstanceCheck.*
|
||||
- --system-talk-name=org.freedesktop.UDisks2
|
||||
# set dark theme
|
||||
- --env=BAMBU_STUDIO_DARK_THEME=false
|
||||
|
||||
modules:
|
||||
|
||||
# JPEG codec for the liveview
|
||||
- name: gst-plugins-good
|
||||
buildsystem: meson
|
||||
config-opts:
|
||||
- -Dauto_features=disabled
|
||||
- -Djpeg=enabled
|
||||
- -Ddoc=disabled
|
||||
- -Dexamples=disabled
|
||||
- -Dtests=disabled
|
||||
sources:
|
||||
- type: archive
|
||||
url: https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.22.8.tar.xz
|
||||
sha256: e305b9f07f52743ca481da0a4e0c76c35efd60adaf1b0694eb3bb021e2137e39
|
||||
|
||||
# xprop, xlib is needed to manipulate the X11 window and set _GTK_THEME_VARIANT dark on X11
|
||||
# and paint the window dark when PRUSA_SLICER_DARK_THEME is true
|
||||
# see: entrypoint & set-dark-theme-variant.py (originated from spotify client flatpak)
|
||||
- name: xprop
|
||||
sources:
|
||||
- type: archive
|
||||
url: http://mirrors.ircam.fr/pub/x.org/individual/app/xprop-1.2.5.tar.gz
|
||||
sha256: b7bf6b6be6cf23e7966a153fc84d5901c14f01ee952fbd9d930aa48e2385d670
|
||||
- name: python-setuptools_scm
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- pip3 install --no-deps --no-build-isolation --verbose --prefix=${FLATPAK_DEST} .
|
||||
sources:
|
||||
- type: archive
|
||||
url: https://files.pythonhosted.org/packages/57/38/930b1241372a9f266a7df2b184fb9d4f497c2cef2e016b014f82f541fe7c/setuptools_scm-6.0.1.tar.gz
|
||||
sha256: d1925a69cb07e9b29416a275b9fadb009a23c148ace905b2fb220649a6c18e92
|
||||
- name: python-xlib
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- pip3 install --no-deps --no-build-isolation --verbose --prefix=${FLATPAK_DEST} .
|
||||
sources:
|
||||
- type: archive
|
||||
url: https://files.pythonhosted.org/packages/86/f5/8c0653e5bb54e0cbdfe27bf32d41f27bc4e12faa8742778c17f2a71be2c0/python-xlib-0.33.tar.gz
|
||||
sha256: 55af7906a2c75ce6cb280a584776080602444f75815a7aff4d287bb2d7018b32
|
||||
|
||||
# For libOSMesa
|
||||
- name: mesa
|
||||
buildsystem: meson
|
||||
config-opts:
|
||||
- -Dosmesa=classic
|
||||
- -Ddri-drivers=[]
|
||||
- -Dgallium-drivers=[]
|
||||
- -Dvulkan-drivers=[]
|
||||
- -Dplatforms=[]
|
||||
build-options:
|
||||
arch:
|
||||
aarch64:
|
||||
config-opts:
|
||||
- -Dlibunwind=disabled
|
||||
cleanup:
|
||||
- /share/drirc.d
|
||||
- /include
|
||||
- "*.a"
|
||||
sources:
|
||||
- type: archive
|
||||
url: https://archive.mesa3d.org/mesa-20.2.6.tar.xz
|
||||
sha256: f12ca3c6c622f11cd79ad66b4220f04514fa96f795062fe92a37339ab19885db
|
||||
|
||||
- name: glu
|
||||
config-opts:
|
||||
- --disable-static
|
||||
sources:
|
||||
- type: archive
|
||||
url: https://ftp.osuosl.org/pub/blfs/conglomeration/glu/glu-9.0.2.tar.xz
|
||||
sha256: 6e7280ff585c6a1d9dfcdf2fca489251634b3377bfc33c29e4002466a38d02d4
|
||||
cleanup:
|
||||
- /include
|
||||
- /lib/*.a
|
||||
- /lib/*.la
|
||||
- /lib/pkgconfig
|
||||
|
||||
- name: kde-extra-cmake-modules
|
||||
buildsystem: cmake-ninja
|
||||
sources:
|
||||
- type: git
|
||||
url: https://github.com/KDE/extra-cmake-modules
|
||||
tag: v5.249.0
|
||||
cleanup:
|
||||
- /
|
||||
|
||||
- name: orca_wxwidgets
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- |
|
||||
mkdir builddir && cd builddir
|
||||
cmake ../ -GNinja \
|
||||
-DwxBUILD_PRECOMP=ON \
|
||||
-DwxBUILD_TOOLKIT=gtk3 \
|
||||
-DwxBUILD_DEBUG_LEVEL=0 \
|
||||
-DwxBUILD_SAMPLES=OFF \
|
||||
-DwxBUILD_SHARED=ON \
|
||||
-DwxUSE_MEDIACTRL=ON \
|
||||
-DwxUSE_DETECT_SM=OFF \
|
||||
-DwxUSE_UNICODE=ON \
|
||||
-DwxUSE_PRIVATE_FONTS=ON \
|
||||
-DwxUSE_OPENGL=ON \
|
||||
-DwxUSE_WEBREQUEST=ON \
|
||||
-DwxUSE_WEBVIEW=ON \
|
||||
-DwxUSE_WEBVIEW_EDGE=OFF \
|
||||
-DwxUSE_WEBVIEW_IE=OFF \
|
||||
-DwxUSE_REGEX=builtin \
|
||||
-DwxUSE_LIBSDL=OFF \
|
||||
-DwxUSE_XTEST=OFF \
|
||||
-DwxUSE_STC=OFF \
|
||||
-DwxUSE_AUI=ON \
|
||||
-DwxUSE_LIBPNG=sys \
|
||||
-DwxUSE_ZLIB=sys \
|
||||
-DwxUSE_LIBJPEG=sys \
|
||||
-DwxUSE_LIBTIFF=sys \
|
||||
-DwxUSE_EXPAT=sys \
|
||||
-DBUILD_SHARED_LIBS:BOOL=ON \
|
||||
-DCMAKE_INSTALL_PREFIX:STRING=/app \
|
||||
-DCMAKE_PREFIX_PATH=/app \
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build . --target install -j$FLATPAK_BUILDER_N_JOBS
|
||||
sources:
|
||||
- type: git
|
||||
url: https://github.com/SoftFever/Orca-deps-wxWidgets
|
||||
branch: master
|
||||
path: ../
|
||||
cleanup:
|
||||
- "*.la"
|
||||
- "*.a"
|
||||
- "*.cmake"
|
||||
- /include
|
||||
- /app/bin/*
|
||||
|
||||
- name: orca_deps
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
# start build
|
||||
- |
|
||||
mkdir deps/build && cd deps/build
|
||||
cmake ../ \
|
||||
-DDEP_WX_GTK3=ON \
|
||||
-DDEP_DOWNLOAD_DIR=/run/build/orca_deps/external-packages \
|
||||
-DCMAKE_PREFIX_PATH=/app \
|
||||
-DDESTDIR=/app \
|
||||
-DCMAKE_INSTALL_LIBDIR=/app/lib \
|
||||
-DFLATPAK=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=/app
|
||||
cmake --build .
|
||||
rm -r /run/build/orca_deps/external-packages
|
||||
|
||||
cleanup:
|
||||
- /app/include
|
||||
- "*.a"
|
||||
- "*.la"
|
||||
- /app/lib/cmake
|
||||
|
||||
sources:
|
||||
# -
|
||||
# Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* .
|
||||
# -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest.
|
||||
#
|
||||
# NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/
|
||||
# -
|
||||
|
||||
# OrcaSlicer Source Archive
|
||||
- type: dir
|
||||
path: ../
|
||||
|
||||
# Blosc
|
||||
- type: file
|
||||
url: https://github.com/tamasmeszaros/c-blosc/archive/refs/heads/v1.17.0_tm.zip
|
||||
dest: external-packages/Blosc
|
||||
sha256: dcb48bf43a672fa3de6a4b1de2c4c238709dad5893d1e097b8374ad84b1fc3b3
|
||||
|
||||
# Cereal
|
||||
- type: file
|
||||
url: https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.0.zip
|
||||
dest: external-packages/Cereal
|
||||
sha256: 71642cb54658e98c8f07a0f0d08bf9766f1c3771496936f6014169d3726d9657
|
||||
|
||||
# CGAL
|
||||
- type: file
|
||||
url: https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip
|
||||
dest: external-packages/CGAL
|
||||
sha256: d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0
|
||||
|
||||
# GMP
|
||||
- type: file
|
||||
url: https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2
|
||||
dest: external-packages/GMP
|
||||
sha256: eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
|
||||
|
||||
# MPFR
|
||||
- type: file
|
||||
url: https://www.mpfr.org/mpfr-current/mpfr-4.2.1.tar.bz2
|
||||
dest: external-packages/MPFR
|
||||
sha256: b9df93635b20e4089c29623b19420c4ac848a1b29df1cfd59f26cab0d2666aa0
|
||||
|
||||
# NLopt
|
||||
- type: file
|
||||
url: https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz
|
||||
dest: external-packages/NLopt
|
||||
sha256: c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
|
||||
|
||||
# OCCT
|
||||
- type: file
|
||||
url: https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_0.zip
|
||||
dest: external-packages/OCCT
|
||||
sha256: 28334f0e98f1b1629799783e9b4d21e05349d89e695809d7e6dfa45ea43e1dbc
|
||||
|
||||
# OpenCSG
|
||||
- type: file
|
||||
url: https://github.com/floriankirsch/OpenCSG/archive/refs/tags/opencsg-1-4-2-release.zip
|
||||
dest: external-packages/OpenCSG
|
||||
sha256: 51afe0db79af8386e2027d56d685177135581e0ee82ade9d7f2caff8deab5ec5
|
||||
|
||||
# OpenCV
|
||||
- type: file
|
||||
url: https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz
|
||||
dest: external-packages/OpenCV
|
||||
sha256: 1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
|
||||
|
||||
# OpenEXR
|
||||
- type: file
|
||||
url: https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.5.5.zip
|
||||
dest: external-packages/OpenEXR
|
||||
sha256: 0307a3d7e1fa1e77e9d84d7e9a8694583fbbbfd50bdc6884e2c96b8ef6b902de
|
||||
|
||||
# OpenVDB
|
||||
- type: file
|
||||
url: https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip
|
||||
dest: external-packages/OpenVDB
|
||||
sha256: f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81
|
||||
|
||||
# Qhull
|
||||
- type: file
|
||||
url: https://github.com/qhull/qhull/archive/v8.0.1.zip
|
||||
dest: external-packages/Qhull
|
||||
sha256: 5287f5edd6a0372588f5d6640799086a4033d89d19711023ef8229dd9301d69b
|
||||
|
||||
# TBB
|
||||
- type: file
|
||||
url: https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.5.0.zip
|
||||
dest: external-packages/TBB
|
||||
sha256: 83ea786c964a384dd72534f9854b419716f412f9d43c0be88d41874763e7bb47
|
||||
|
||||
# Boost
|
||||
- type: file
|
||||
url: https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz
|
||||
dest: external-packages/Boost
|
||||
sha256: 4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95
|
||||
|
||||
# GLFW
|
||||
- type: file
|
||||
url: https://github.com/glfw/glfw/archive/refs/tags/3.3.7.zip
|
||||
dest: external-packages/GLFW
|
||||
sha256: e02d956935e5b9fb4abf90e2c2e07c9a0526d7eacae8ee5353484c69a2a76cd0
|
||||
|
||||
- name: OrcaSlicer
|
||||
buildsystem: simple
|
||||
build-commands:
|
||||
- |
|
||||
mkdir -p build && cd build
|
||||
CXXFLAGS=-std=gnu++20 cmake ../ \
|
||||
-DSLIC3R_PCH=OFF \
|
||||
-DSLIC3R_FHS=ON \
|
||||
-DSLIC3R_GTK=3 \
|
||||
-DSLIC3R_STATIC=ON \
|
||||
-DSLIC3R_BUILD_TESTS=OFF \
|
||||
-DSLIC3R_DESKTOP_INTEGRATION=OFF \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DFLATPAK=ON \
|
||||
-DBBL_RELEASE_TO_PUBLIC=1 \
|
||||
-DCMAKE_PREFIX_PATH=/app \
|
||||
-DCMAKE_INSTALL_PREFIX=/app
|
||||
CXXFLAGS=-std=gnu++20 cmake --build . --target install -j$FLATPAK_BUILDER_N_JOBS
|
||||
|
||||
cleanup:
|
||||
- /include
|
||||
|
||||
post-install:
|
||||
|
||||
- | # Desktop Integration files
|
||||
install -Dm644 -t /app/share/icons/hicolor/scalable/apps/ resources/images/OrcaSlicer.svg
|
||||
install -Dm644 ${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml
|
||||
mv /app/share/applications/OrcaSlicer.desktop /app/share/applications/${FLATPAK_ID}.desktop
|
||||
desktop-file-edit --set-key=Exec --set-value="entrypoint %U" /app/share/applications/${FLATPAK_ID}.desktop
|
||||
install -Dm755 set-dark-theme-variant.py /app/bin
|
||||
install -Dm755 entrypoint /app/bin
|
||||
install -Dm755 umount /app/bin
|
||||
|
||||
sources:
|
||||
# -
|
||||
# Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* .
|
||||
# -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest.
|
||||
#
|
||||
# NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/
|
||||
# -
|
||||
|
||||
# OrcaSlicer Source Archive
|
||||
- type: dir
|
||||
path: ../
|
||||
|
||||
# AppData metainfo for Gnome Software & Co.
|
||||
- type: file
|
||||
path: io.github.softfever.OrcaSlicer.metainfo.xml
|
||||
|
||||
# script to set dark theme variant
|
||||
- type: file
|
||||
path: set-dark-theme-variant.py
|
||||
|
||||
# start-up script
|
||||
# README: workaround for the following issues, also enables dark theme variant:
|
||||
# SEE: https://github.com/flathub/com.bambulab.BambuStudio/issues/27
|
||||
# SEE: https://github.com/flathub/com.bambulab.BambuStudio/issues/3
|
||||
# SEE: https://github.com/prusa3d/PrusaSlicer/issues/2365
|
||||
- type: file
|
||||
path: entrypoint
|
||||
|
||||
# umount wrapper used to redirect umount calls to udisk2
|
||||
- type: file
|
||||
path: umount
|
||||
85
flatpak/set-dark-theme-variant.py
Normal file
85
flatpak/set-dark-theme-variant.py
Normal file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import Xlib
|
||||
import Xlib.display
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
disp = Xlib.display.Display()
|
||||
root = disp.screen().root
|
||||
|
||||
NET_CLIENT_LIST = disp.intern_atom('_NET_CLIENT_LIST')
|
||||
|
||||
|
||||
def set_theme_variant_by_window_id(id, variant):
|
||||
# Use subprocess to call
|
||||
# xprop and set the variant from id.
|
||||
try:
|
||||
s = subprocess.call(['xprop', '-f', '_GTK_THEME_VARIANT', '8u', '-set', '_GTK_THEME_VARIANT', variant, '-id', str(id)],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
if s == 0:
|
||||
return True
|
||||
return False
|
||||
except Exception as ex:
|
||||
return False
|
||||
|
||||
|
||||
def set_theme_variant_from_win_id_collection(win_id_collection, variant):
|
||||
# Loop though all of the collected
|
||||
# window ids and set theme variant
|
||||
for win_id in win_id_collection:
|
||||
set_theme_variant_by_window_id(win_id, variant)
|
||||
|
||||
|
||||
def collection_win_id_from_wm_class_name(win_class_name):
|
||||
|
||||
collect = []
|
||||
|
||||
# Loop though all of the windows
|
||||
# and collect id's those that match
|
||||
# win_class: prusa-slicer
|
||||
for win_id in root.get_full_property(NET_CLIENT_LIST, Xlib.X.AnyPropertyType).value:
|
||||
try:
|
||||
win = disp.create_resource_object('window', win_id)
|
||||
if not win.get_wm_transient_for():
|
||||
win_class = win.get_wm_class()
|
||||
if win_id and win_class_name in win_class:
|
||||
collect.append(
|
||||
win_id) if win_id not in collect else collect
|
||||
except Xlib.error.BadWindow:
|
||||
pass
|
||||
|
||||
return collect
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if os.environ.get('PRUSA_SLICER_DARK_THEME', 'false') != 'true':
|
||||
sys.exit(0)
|
||||
|
||||
# Listen for X Property Change events.
|
||||
root.change_attributes(event_mask=Xlib.X.PropertyChangeMask)
|
||||
# the class name of the slicer window
|
||||
win_class_name = 'prusa-slicer'
|
||||
# the variant to set
|
||||
variant = 'dark'
|
||||
|
||||
start = time.time()
|
||||
|
||||
while True:
|
||||
# collect all of the window ids
|
||||
collect = collection_win_id_from_wm_class_name(win_class_name)
|
||||
# give PrusaSlicer window 2 secs to
|
||||
# collect the wanted window ids
|
||||
# set the theme variant and exit
|
||||
if time.time() - start <= 2:
|
||||
# disp.next_event() blocks if no events are
|
||||
# queued. In combination with while True
|
||||
# it creates a very simple event loop.
|
||||
disp.next_event()
|
||||
set_theme_variant_from_win_id_collection(collect, variant)
|
||||
else:
|
||||
break
|
||||
10
flatpak/umount
Executable file
10
flatpak/umount
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments supplied"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEVICE=$(basename $(findmnt -oSOURCE -n "$@") )
|
||||
|
||||
exec /usr/bin/gdbus call -y -d org.freedesktop.UDisks2 -o /org/freedesktop/UDisks2/block_devices/$DEVICE -m org.freedesktop.UDisks2.Filesystem.Unmount "{'b': <'false'>}" 1> /dev/null
|
||||
|
||||
Reference in New Issue
Block a user