snap: fix packaging for gtk app

This commit is contained in:
shadeyg56 2023-08-16 02:06:24 -05:00
parent 704a968f83
commit df6192298e
3 changed files with 14 additions and 32 deletions

View File

@ -11,7 +11,12 @@ sys.path.append("../")
from auto_cpufreq.core import is_running from auto_cpufreq.core import is_running
from auto_cpufreq.gui.objects import RadioButtonView, SystemStatsLabel, CPUFreqStatsLabel, CurrentGovernorBox, DropDownMenu, DaemonNotRunningView from auto_cpufreq.gui.objects import RadioButtonView, SystemStatsLabel, CPUFreqStatsLabel, CurrentGovernorBox, DropDownMenu, DaemonNotRunningView
CSS_FILE = "/usr/local/share/auto-cpufreq/scripts/style.css" if os.getenv("PKG_MARKER") == "SNAP":
ICON_FILE = "/snap/auto-cpufreq/current/icon.png"
CSS_FILE = "/snap/auto-cpufreq/current/style.css"
else:
ICON_FILE = "/usr/local/share/auto-cpufreq/images/icon.png"
CSS_FILE = "/usr/local/share/auto-cpufreq/scripts/style.css"
HBOX_PADDING = 20 HBOX_PADDING = 20
@ -22,7 +27,7 @@ class ToolWindow(Gtk.Window):
self.set_border_width(10) self.set_border_width(10)
self.set_resizable(False) self.set_resizable(False)
self.load_css() self.load_css()
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename="/usr/local/share/auto-cpufreq/images/icon.png", width=500, height=500, preserve_aspect_ratio=True) pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename=ICON_FILE, width=500, height=500, preserve_aspect_ratio=True)
self.set_icon(pixbuf) self.set_icon(pixbuf)
self.build() self.build()

View File

@ -3,7 +3,7 @@ Type=Application
Encoding=UTF-8 Encoding=UTF-8
Name=auto-cpufreq Name=auto-cpufreq
Comment=Automatic CPU speed & power optimizer for Linux Comment=Automatic CPU speed & power optimizer for Linux
Exec=auto-cpufreq-gtk Exec=auto-cpufreq.auto-cpufreq-gtk
StartupWMClass=app.py StartupWMClass=app.py
Terminal=false Terminal=false
Icon=${SNAP}/meta/gui/auto-cpufreq.png Icon=${SNAP}/meta/gui/auto-cpufreq.png

View File

@ -24,8 +24,6 @@ parts:
build-packages: build-packages:
- gcc - gcc
- python3-dev - python3-dev
- libgirepository1.0-dev
- libcairo2-dev
stage-packages: stage-packages:
- coreutils - coreutils
- dmidecode - dmidecode
@ -34,25 +32,6 @@ parts:
snapcraftctl pull snapcraftctl pull
snapcraftctl set-version `grep ^VERSION $SNAPCRAFT_PART_SRC/setup.py | sed 's/.*"\(.*\)"/\1/'` snapcraftctl set-version `grep ^VERSION $SNAPCRAFT_PART_SRC/setup.py | sed 's/.*"\(.*\)"/\1/'`
auto-cpufreq-gtk:
plugin: python
python-packages:
- setuptools
- wheel
- requests
build-packages:
- gcc
- python3-dev
- libgirepository1.0-dev
- libcairo2-dev
stage-packages:
- coreutils
- dmidecode
source: .
# override-pull: |
# snapcraftctl pull
# snapcraftctl set-version `grep ^VERSION $SNAPCRAFT_PART_SRC/setup.py | sed 's/.*"\(.*\)"/\1/'`
deploy-scripts: deploy-scripts:
plugin: dump plugin: dump
source: scripts source: scripts
@ -60,11 +39,9 @@ parts:
cpufreqctl.sh: usr/bin/cpufreqctl.auto-cpufreq cpufreqctl.sh: usr/bin/cpufreqctl.auto-cpufreq
snapdaemon.sh: usr/bin/snapdaemon snapdaemon.sh: usr/bin/snapdaemon
# deploy-auto-cpufreq-gtk: copy-image:
# plugin: dump plugin: dump
# source: bin source: images
# organize:
# auto-cpufreq-gtk: usr/bin/auto-cpufreq-gtk
plugs: plugs:
etc-auto-cpufreq-conf: etc-auto-cpufreq-conf:
@ -85,9 +62,10 @@ apps:
- system-observe - system-observe
- hardware-observe - hardware-observe
- etc-auto-cpufreq-conf - etc-auto-cpufreq-conf
auto-cpufreq-gtk: auto-cpufreq-gtk:
command: bin/auto-cpufreq-gtk command: bin/auto-cpufreq-gtk
#desktop: usr/share/applications/auto-cpufreq.desktop extensions: [gnome]
environment: environment:
PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
LC_ALL: C.UTF-8 LC_ALL: C.UTF-8
@ -101,14 +79,13 @@ apps:
- cpu-control - cpu-control
- system-observe - system-observe
- hardware-observe - hardware-observe
- etc-auto-cpufreq-conf
service: service:
command: usr/bin/snapdaemon command: usr/bin/snapdaemon
plugs: plugs:
- cpu-control - cpu-control
- system-observe - system-observe
- hardware-observe - hardware-observe
- etc-auto-cpufreq-conf
environment: environment:
LC_ALL: C.UTF-8 LC_ALL: C.UTF-8
LANG: C.UTF-8 LANG: C.UTF-8