Skip to content

Commit

Permalink
Multi monitor feature for video (#153)
Browse files Browse the repository at this point in the history
* Added multi monitor feature for local videos

- Created a menu when user clicked on apply to set to which monitor
- Updated VideoPlayer to work well for multi monitor support.

* Monitor module moved and default config template set

* Added pip requirement

Only tested with specific version of screeninfo

* Added mute when maximized window added

- Added option to mute audio when focused maximized/fullscreen instance
- Added right click context menu to selection of monitor for each item
- Update meson file to add monitor.py

* Added state for checking is it same with last

* Fixed a bug

- Fixed bug when mute when maximized option is enabled. There was no
  voice although it minimized window on first startup.

* Added changes for reviews

* Monitor initialize on default config

* Monitors changed into dict instead of list

* Some changes for working on multiple monitors with new implementation of config

* Migration from old config to this implementation should be handled as write into default section in dict.

* If there is no video source on monitor must be handled to default.

* Fixed bug on set for all option

* Checking missing monitors and default section added

* Fixed bug on setting default value from another sources

* WebPage and Stream modes handled with Default source

* fix: set_static_wallpaper
`expected str, bytes or os.PathLike object, not dict`

* change: config and method

* fix: config migration

* Default section removed from selection list and will update on every source change

* change: bump version

---------

Co-authored-by: jeffshee <[email protected]>
  • Loading branch information
xaprier and jeffshee authored Jan 3, 2025
1 parent 5dad40a commit c575020
Show file tree
Hide file tree
Showing 11 changed files with 503 additions and 142 deletions.
9 changes: 8 additions & 1 deletion data/io.github.jeffshee.Hidamari.appdata.xml.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<component type="desktop-application">
<!--Created with jdAppStreamEdit 9.1-->
<!--Created with jdAppStreamEdit 9.2-->
<id>io.github.jeffshee.Hidamari</id>
<name>Hidamari</name>
<summary>Video wallpaper for Linux</summary>
Expand All @@ -27,6 +27,13 @@
</screenshot>
</screenshots>
<releases>
<release version="3.6" date="2025-01-03" type="stable">
<description>
<ul>
<li>Add multi monitor feature for video (@xaprier)</li>
</ul>
</description>
</release>
<release version="3.5" date="2024-06-30" type="stable">
<description>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('hidamari',
version: '3.5',
version: '3.6',
license: ['GPL-3.0'],
meson_version: '>= 0.59.0',
default_options: [ 'warning_level=2',
Expand Down
39 changes: 27 additions & 12 deletions src/assets/control.ui
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,35 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
</packing>
</child>
<child>
<object class="GtkModelButton" id="ToggleDetectMaximized">
<object class="GtkModelButton" id="TogglePauseWhenMaximized">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Automatically pauses playback when maximized window or full screen mode is detected</property>
<property name="action-name">app.detect_maximized</property>
<property name="text" translatable="yes">Detect maximized window</property>
<property name="action-name">app.pause_when_maximized</property>
<property name="text" translatable="yes">Pause when maximized window</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="ToggleMuteWhenMaximized">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Automatically mutes playback when maximized window or full screen mode is detected</property>
<property name="action-name">app.mute_when_maximized</property>
<property name="text" translatable="yes">Mute when maximized window</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
Expand All @@ -136,7 +151,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
Expand All @@ -152,7 +167,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -197,7 +212,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
<child>
Expand All @@ -213,7 +228,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">8</property>
</packing>
</child>
<child>
Expand All @@ -228,7 +243,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
<property name="position">9</property>
</packing>
</child>
<child>
Expand All @@ -239,7 +254,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
<property name="position">10</property>
</packing>
</child>
<child>
Expand All @@ -253,7 +268,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
<property name="position">11</property>
</packing>
</child>
<child>
Expand All @@ -267,7 +282,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">11</property>
<property name="position">12</property>
</packing>
</child>
<child>
Expand All @@ -281,7 +296,7 @@ All Contributors https://github.com/jeffshee/hidamari/graphs/contributors</prope
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">12</property>
<property name="position">13</property>
</packing>
</child>
</object>
Expand Down
35 changes: 26 additions & 9 deletions src/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
HOME = os.environ.get("HOME")
try:
xdg_video_dir = subprocess.check_output(
"xdg-user-dir VIDEOS", shell=True, encoding='UTF-8').replace("\n", "")
"xdg-user-dir VIDEOS", shell=True, encoding="UTF-8"
).replace("\n", "")
VIDEO_WALLPAPER_DIR = os.path.join(xdg_video_dir, "Hidamari")
except FileNotFoundError:
# xdg-user-dir not found, use $HOME/Hidamari for Video directory instead
Expand All @@ -19,8 +20,7 @@
xdg_config_home = os.environ.get("XDG_CONFIG_HOME", os.path.join(HOME, ".config"))
AUTOSTART_DIR = os.path.join(xdg_config_home, "autostart")
AUTOSTART_DESKTOP_PATH = os.path.join(AUTOSTART_DIR, f"{PROJECT}.desktop")
AUTOSTART_DESKTOP_CONTENT = \
"""[Desktop Entry]
AUTOSTART_DESKTOP_CONTENT = """[Desktop Entry]
Name=Hidamari
Exec=hidamari -b
Icon=io.github.jeffshee.Hidamari
Expand All @@ -29,8 +29,7 @@
Categories=GTK;Utility;
StartupNotify=true
"""
AUTOSTART_DESKTOP_CONTENT_FLATPAK = \
"""[Desktop Entry]
AUTOSTART_DESKTOP_CONTENT_FLATPAK = """[Desktop Entry]
Name=Hidamari
Exec=/usr/bin/flatpak run --command=hidamari io.github.jeffshee.Hidamari -b
Icon=io.github.jeffshee.Hidamari
Expand All @@ -49,15 +48,16 @@
MODE_STREAM = "MODE_STREAM"
MODE_WEBPAGE = "MODE_WEBPAGE"

CONFIG_VERSION = 3
CONFIG_VERSION = 4
CONFIG_KEY_VERSION = "version"
CONFIG_KEY_MODE = "mode"
CONFIG_KEY_DATA_SOURCE = "data_source"
CONFIG_KEY_MUTE = "is_mute"
CONFIG_KEY_VOLUME = "audio_volume"
CONFIG_KEY_STATIC_WALLPAPER = "is_static_wallpaper"
CONFIG_KEY_BLUR_RADIUS = "static_wallpaper_blur_radius"
CONFIG_KEY_DETECT_MAXIMIZED = "is_detect_maximized"
CONFIG_KEY_PAUSE_WHEN_MAXIMIZED = "is_pause_when_maximized"
CONFIG_KEY_MUTE_WHEN_MAXIMIZED = "is_mute_when_maximized"
CONFIG_KEY_FADE_DURATION_SEC = "fade_duration_sec"
CONFIG_KEY_FADE_INTERVAL = "fade_interval"
CONFIG_KEY_SYSTRAY = "is_show_systray"
Expand All @@ -70,9 +70,26 @@
CONFIG_KEY_VOLUME: 50,
CONFIG_KEY_STATIC_WALLPAPER: True,
CONFIG_KEY_BLUR_RADIUS: 5,
CONFIG_KEY_DETECT_MAXIMIZED: False,
CONFIG_KEY_PAUSE_WHEN_MAXIMIZED: True,
CONFIG_KEY_MUTE_WHEN_MAXIMIZED: False,
CONFIG_KEY_FADE_DURATION_SEC: 1.5,
CONFIG_KEY_FADE_INTERVAL: 0.1,
CONFIG_KEY_SYSTRAY: False,
CONFIG_KEY_FIRST_TIME: True
CONFIG_KEY_FIRST_TIME: True,
}

try:
from monitor import Monitor, Monitors, MonitorInfo
except ModuleNotFoundError:
from hidamari.monitor import Monitor, Monitors, MonitorInfo

# initialize config according to monitors
info = MonitorInfo()
monitors = info.monitors()
data_sources = {}
# create an
for monitor in monitors:
data_sources[monitor['name']] = ""
data_sources['Default'] = ""

CONFIG_TEMPLATE[CONFIG_KEY_DATA_SOURCE] = data_sources
Loading

1 comment on commit c575020

@shynekomaid
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks!!!

Please sign in to comment.