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 055f7f9..0000000 Binary files a/usr/share/sonist/play_a.png and /dev/null differ