From 4ec76969110b1eb39c3d3589bd254cdbefe863aa Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 25 Aug 2023 16:33:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 21 ++++++++++++++++++ test.sh | 5 +++++ usr/bin/sonist | 3 +++ about_app.py => usr/lib/sonist/about_app.py | 0 mpd.py => usr/lib/sonist/mpd.py | 0 .../lib/sonist/preferences.py | 0 main.py => usr/lib/sonist/sonist.py | 4 ++++ {ui => usr/lib/sonist/ui}/ctrl_box.py | 8 +++++-- {ui => usr/lib/sonist/ui}/image.py | 0 {ui => usr/lib/sonist/ui}/image_button.py | 0 {ui => usr/lib/sonist/ui}/option_menu.py | 0 {ui => usr/lib/sonist/ui}/timebar.py | 0 {ui => usr/lib/sonist/ui}/title_text.py | 0 {ui => usr/lib/sonist/ui}/toggle_button.py | 0 {ui => usr/lib/sonist/ui}/volume.py | 0 utils.py => usr/lib/sonist/utils.py | 0 window.py => usr/lib/sonist/window.py | 17 ++++++-------- usr/share/sonist/play_a.png | Bin 1773 -> 0 bytes 18 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 LICENSE create mode 100755 test.sh create mode 100755 usr/bin/sonist rename about_app.py => usr/lib/sonist/about_app.py (100%) rename mpd.py => usr/lib/sonist/mpd.py (100%) rename preferences.py => usr/lib/sonist/preferences.py (100%) rename main.py => usr/lib/sonist/sonist.py (96%) rename {ui => usr/lib/sonist/ui}/ctrl_box.py (93%) rename {ui => usr/lib/sonist/ui}/image.py (100%) rename {ui => usr/lib/sonist/ui}/image_button.py (100%) rename {ui => usr/lib/sonist/ui}/option_menu.py (100%) rename {ui => usr/lib/sonist/ui}/timebar.py (100%) rename {ui => usr/lib/sonist/ui}/title_text.py (100%) rename {ui => usr/lib/sonist/ui}/toggle_button.py (100%) rename {ui => usr/lib/sonist/ui}/volume.py (100%) rename utils.py => usr/lib/sonist/utils.py (100%) rename window.py => usr/lib/sonist/window.py (93%) delete mode 100644 usr/share/sonist/play_a.png diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ab60297 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..158761f --- /dev/null +++ b/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export SONIST_LIB_DIR=$(pwd) + +./usr/lib/sonist/sonist.py \ No newline at end of file diff --git a/usr/bin/sonist b/usr/bin/sonist new file mode 100755 index 0000000..3ecd4cb --- /dev/null +++ b/usr/bin/sonist @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/lib/sonist/sonist.py \ No newline at end of file diff --git a/about_app.py b/usr/lib/sonist/about_app.py similarity index 100% rename from about_app.py rename to usr/lib/sonist/about_app.py diff --git a/mpd.py b/usr/lib/sonist/mpd.py similarity index 100% rename from mpd.py rename to usr/lib/sonist/mpd.py diff --git a/preferences.py b/usr/lib/sonist/preferences.py similarity index 100% rename from preferences.py rename to usr/lib/sonist/preferences.py diff --git a/main.py b/usr/lib/sonist/sonist.py similarity index 96% rename from main.py rename to usr/lib/sonist/sonist.py index 08e1214..d297097 100755 --- a/main.py +++ b/usr/lib/sonist/sonist.py @@ -38,6 +38,10 @@ class Application(Gtk.Application): def __init__(self): Gtk.Application.__init__(self, application_id = app_id) + self.lib_dir = f"{os.getenv('SONIST_LIB_DIR')}/" if os.getenv('SONIST_LIB_DIR') else '' + + print(self.lib_dir) + self.music_dir = get_music_dir() self.album_cache_dir = f"{home_dir}/.cache/sonist/album" self.lyric_cache_dir = f"{home_dir}/.cache/sonist/lyric" diff --git a/ui/ctrl_box.py b/usr/lib/sonist/ui/ctrl_box.py similarity index 93% rename from ui/ctrl_box.py rename to usr/lib/sonist/ui/ctrl_box.py index 77577e2..fd69c2c 100644 --- a/ui/ctrl_box.py +++ b/usr/lib/sonist/ui/ctrl_box.py @@ -20,12 +20,16 @@ class CtrlBox(Gtk.Box): self.disabled = True - self.modes = ['./usr/share/sonist/all.png','./usr/share/sonist/rand.png','./usr/share/sonist/single.png'] + self.modes = [ + './usr/share/sonist/all.png', + './usr/share/sonist/rand.png', + './usr/share/sonist/single.png' + ] self.curr_mode = 0 self.mode_btn = ImageButton(self.modes[0]) self.prev_btn = ImageButton('./usr/share/sonist/prev.png') - self.play_btn = ToggleButton(['./usr/share/sonist/pause.png', './usr/share/sonist/play.png', './usr/share/sonist/play_a.png'], 48, 48) + self.play_btn = ToggleButton(['./usr/share/sonist/pause.png', './usr/share/sonist/play.png'], 48, 48) self.next_btn = ImageButton('./usr/share/sonist/next.png') self.vol_btn = ImageButton('./usr/share/sonist/volume.png') diff --git a/ui/image.py b/usr/lib/sonist/ui/image.py similarity index 100% rename from ui/image.py rename to usr/lib/sonist/ui/image.py diff --git a/ui/image_button.py b/usr/lib/sonist/ui/image_button.py similarity index 100% rename from ui/image_button.py rename to usr/lib/sonist/ui/image_button.py diff --git a/ui/option_menu.py b/usr/lib/sonist/ui/option_menu.py similarity index 100% rename from ui/option_menu.py rename to usr/lib/sonist/ui/option_menu.py diff --git a/ui/timebar.py b/usr/lib/sonist/ui/timebar.py similarity index 100% rename from ui/timebar.py rename to usr/lib/sonist/ui/timebar.py diff --git a/ui/title_text.py b/usr/lib/sonist/ui/title_text.py similarity index 100% rename from ui/title_text.py rename to usr/lib/sonist/ui/title_text.py diff --git a/ui/toggle_button.py b/usr/lib/sonist/ui/toggle_button.py similarity index 100% rename from ui/toggle_button.py rename to usr/lib/sonist/ui/toggle_button.py diff --git a/ui/volume.py b/usr/lib/sonist/ui/volume.py similarity index 100% rename from ui/volume.py rename to usr/lib/sonist/ui/volume.py diff --git a/utils.py b/usr/lib/sonist/utils.py similarity index 100% rename from utils.py rename to usr/lib/sonist/utils.py diff --git a/window.py b/usr/lib/sonist/window.py similarity index 93% rename from window.py rename to usr/lib/sonist/window.py index 820be07..9a381b7 100644 --- a/window.py +++ b/usr/lib/sonist/window.py @@ -51,24 +51,21 @@ class SonistWindow(Gtk.Window): self.set_opacity(0.9) - # self.set_keep_above(True) - - # album_img = './usr/share/sonist/album.png' - album_img = './usr/share/sonist/avatar.jpg' + album_img = f'{self.app.lib_dir}/usr/share/sonist/avatar.jpg' self.set_background_image(album_img) layout = Gtk.Layout() # 菜单按钮 - menu_btn = ImageButton('./usr/share/sonist/menu.png') + menu_btn = ImageButton(f'{self.app.lib_dir}/usr/share/sonist/menu.png') popup_menu = OptionMenu(app) menu_btn.connect('clicked', lambda btn: popup_menu.show(btn)) layout.put(menu_btn, 276, 6) # 唱片 - disk = ScaleImage('./usr/share/sonist/disk.png') - handler = ScaleImage('./usr/share/sonist/handler.png') + disk = ScaleImage(f'{self.app.lib_dir}/usr/share/sonist/disk.png') + handler = ScaleImage(f'{self.app.lib_dir}/usr/share/sonist/handler.png') album = ScaleImage(album_img) disk.resize(192, 192) @@ -114,7 +111,7 @@ class SonistWindow(Gtk.Window): provider = Gtk.CssProvider() css = f""" #SonistWindow {{ - background-image: url('./usr/share/sonist/album.png'); + background-image: url('{self.app.lib_dir}/usr/share/sonist/album.png'); background-size: 100% 100%; background-position: center; }} @@ -256,9 +253,9 @@ class SonistWindow(Gtk.Window): def update_play_stat(self, is_play = True): if is_play: - self.handler.reset('./usr/share/sonist/handler_a.png') + self.handler.reset(f'{self.app.lib_dir}/usr/share/sonist/handler_a.png') else: - self.handler.reset('./usr/share/sonist/handler.png') + self.handler.reset(f'{self.app.lib_dir}/usr/share/sonist/handler.png') # 切换播放按钮状态 self.ctrl_box.toggle_play_btn(is_play) diff --git a/usr/share/sonist/play_a.png b/usr/share/sonist/play_a.png deleted file mode 100644 index 055f7f9e868a3d03be0874e6e3fedefc203cab5d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1773 zcmeHH`!^E`9N#V~(?VF15z4!qJWAeUWs=u$^9=K--D}sF$LKDpkT!;Sgk`n7Lr9`f zCeJc?O!K%1_flTl!kU?`{*8O?Ip5FsbH3;E`RRK;=ac5@Y!3!0fdBvi*Z~1Y?lIyg z4v6h-l#yM`9szMkdt2ampMK)rA&EtJ;{X6Dxt{<63aN^F2Bzy}j|+R^lXlYo^WXTu zxtN`wK`4wyI=cg;5r3BV&VT#Sr;O{`QL%b%ZNm@^P=YN~4<0Sq?FduwhGev*XW$_M*x8MVFx(O15aJ`5(Zp`$3?^2uKHD{356QORL5Q|I zAG(aK7kNPh;?8U{+it|IPZbDx6f$|;0Jm0PH1n{hz-UoF_y?D)<|?mWe8rG<{iXvt zvQC?GO+Qo$l1I74OO}EN$|?_ddqw#@z7$~W$(pFcI+dJ#W!mi(9@%&nDL0nG@+?Mw z&Eo*MaKfF6hzgf?@q^iB5fWxm<<~WiKFTt^!n*QSF3fyaC&*D z!Uvx#<^|P%Bs-weja)i?6kohJMuRSoMX;MI`%t6pM=$y+QSrZ+uor4t$V_@IX8W;Y ztZ)67N$8HzIM`)8OSm+i%~u(Z+TU7j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