Skip to content

Commit aebe43a

Browse files
authored
Merge pull request #1 from cassidyjames/fullscreen
Fullscreen: Hide HeaderBar, add Toast
2 parents 786900c + 3aa964b commit aebe43a

File tree

8 files changed

+127
-28
lines changed

8 files changed

+127
-28
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
[![Flathub](https://img.shields.io/flathub/v/com.cassidyjames.butler?logo=flathub&logoColor=white&style=for-the-badge)][flathub]
2+
[![Installs](https://img.shields.io/flathub/downloads/com.cassidyjames.butler?label=Installs&logo=flathub&logoColor=white&style=for-the-badge)][flathub]
3+
4+
![Icon](data/icons/app.svg?raw=true)
5+
16
# Butler for Home Assistant
27

38
**Control your smart home**
49

5-
![Screenshot](https://raw.githubusercontent.com/cassidyjames/butler/1.0.0/data/screenshots/light.png)
10+
![Screenshot](data/screenshots/light.png)
611

712
Hybrid native + web app for Home Assistant. Butler wraps your Home Assistant dashboard up in a native UI, integrating better with your OS. Native features include:
813

@@ -17,8 +22,21 @@ Other features include:
1722
- Pinch-to-zoom
1823
- Set the scaling with Ctrl+Plus/Minus or Ctrl+0 to reset
1924

25+
## Made for GNOME
26+
27+
Butler is designed and developed on and for GNOME. As such, contributors agree to abide by the [GNOME Code of Conduct](https://wiki.gnome.org/Foundation/CodeOfConduct).
28+
29+
<a href='https://flathub.org/apps/details/com.cassidyjames.butler'><img width='196' alt='Download on Flathub' src='https://flathub.org/assets/badges/flathub-badge-en.svg'/></a>
30+
2031
## Why not a web browser or PWA?
2132

2233
I don't love the state of web apps and PWAs on Linux; I prefer GNOME Web or Firefox, but the former doesn't truly support PWAs (just web apps with not-that-lightweight of a UI) and the latter doesn't support PWAs on the desktop at all. So, I made this dumb little web wrapper to give myself a bit more integrated of an experience.
2334

2435
If there's more interest in making this into a better-integrated companion app for Linux, I welcome contributions!
36+
37+
## Developing and Building
38+
39+
I recommend using GNOME Builder for development.
40+
41+
[flathub]: https://flathub.org/apps/details/com.cassidyjames.butler
42+

com.cassidyjames.butler.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{
1616
"name" : "butler",
1717
"buildsystem" : "meson",
18+
"run-tests": true,
1819
"sources" : [
1920
{
2021
"type" : "dir",

data/gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<summary>Home Assistant server URL</summary>
1212
<description>URL for the Home Assistant server; must include protocol and custom ports</description>
1313
</key>
14+
<key name="window-fullscreened" type="b">
15+
<default>false</default>
16+
<summary>Window fullscreened</summary>
17+
<description>Whether the window was fullscreened on last run</description>
18+
</key>
1419
<key name="window-maximized" type="b">
1520
<default>false</default>
1621
<summary>Window maximized</summary>

data/metainfo.xml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,90 @@
22
<!-- Copyright 2024 Cassidy James Blaede <[email protected]> -->
33
<component type="desktop">
44
<id>com.cassidyjames.butler</id>
5-
<name>Butler for Home Assistant</name>
6-
<summary>Control your smart home</summary>
75
<metadata_license>CC-BY-SA-4.0</metadata_license>
86
<project_license>GPL-3.0-or-later</project_license>
7+
8+
<name>Butler for Home Assistant</name>
9+
<summary>Control your smart home</summary>
10+
<developer_name translatable="no">Cassidy James Blaede</developer_name>
11+
<developer id="cassidyjames.com">
12+
<name translatable="no">Cassidy James Blaede</name>
13+
</developer>
914
<description>
1015
<p>Hybrid native + web app for Home Assistant. Butler wraps your Home Assistant dashboard up in a native UI, integrating better with your OS. Native features include:</p>
1116
<ul>
1217
<li>Icon in your App Grid, Applications Menu, Dash, Dock, etc.</li>
1318
<li>Native header bar</li>
1419
<li>Save and restore current view and size when closed and re-opened</li>
1520
<li>Two-finger swipe and mouse button support to go back/forward between views</li>
16-
<li>Cross-desktop light/dark style support for GNOME, elementary OS, etc.</li>
21+
<li>Cross-desktop light/dark style support (if supported by your Lovelace theme)</li>
1722
</ul>
1823
<p>Other features include:</p>
1924
<ul>
2025
<li>Pinch-to-zoom</li>
2126
<li>Set the scaling with Ctrl+Plus/Minus or Ctrl+0 to reset</li>
27+
<li>Fullscreen from the menu, a keyboard shortcut, or a GSetting to better support kiosk use cases</li>
2228
</ul>
29+
<p>Note WebRTC camera streams (i.e. used by some newer Nest cameras) are not currently supported.</p>
2330
</description>
31+
2432
<provides>
2533
<binary>com.cassidyjames.butler</binary>
2634
</provides>
2735
<launchable type="desktop-id">com.cassidyjames.butler.desktop</launchable>
36+
37+
<branding>
38+
<color type="primary">#03a9f5</color>
39+
</branding>
40+
2841
<recommends>
29-
<display_length compare="ge">360</display_length>
42+
<display_length compare="ge">300</display_length>
3043
</recommends>
3144
<supports>
3245
<control>pointing</control>
3346
<control>keyboard</control>
3447
<control>touch</control>
3548
</supports>
49+
50+
<screenshots>
51+
<screenshot type="default">
52+
<image>https://raw.githubusercontent.com/cassidyjames/butler/1.0.0/data/screenshots/light.png</image>
53+
<caption>Home Assistant dashboard with many rooms and devices</caption>
54+
</screenshot>
55+
</screenshots>
56+
3657
<releases>
37-
<release version="1.0.0" date="2024-01-03">
58+
<release version="1.0.1" date="2024-01-05">
59+
<description>
60+
<p>Improved accessibility and fullscreen experience</p>
61+
<ul>
62+
<li>Hide header bar when fullscreen</li>
63+
<li>Remember fullscreen state</li>
64+
<li>Remind how to exit fullscreen</li>
65+
<li>Add access keys (mnemonics) for better accessibility</li>
66+
</ul>
67+
</description>
68+
<issues>
69+
<issue url="https://github.com/cassidyjames/butler/issues/12">Hide header bar when fullscreen</issue>
70+
<issue url="https://github.com/cassidyjames/butler/issues/3">Remember fullscreen state</issue>
71+
<issue url="https://github.com/cassidyjames/butler/issues/6">Remind how to exit fullscreen</issue>
72+
<issue url="https://github.com/cassidyjames/butler/issues/7">Add access keys (mnemonics) for better accessibility</issue>
73+
</issues>
74+
</release>
75+
<release version="1.0.0" date="2024-01-04">
3876
<description>
3977
<p>Initial release</p>
4078
</description>
4179
</release>
4280
</releases>
43-
<screenshots>
44-
<screenshot type="default">
45-
<image>https://raw.githubusercontent.com/cassidyjames/butler/1.0.0/data/screenshots/light.png</image>
46-
</screenshot>
47-
</screenshots>
81+
4882
<content_rating type="oars-1.1">
4983
<content_attribute id="social-info">mild</content_attribute>
5084
</content_rating>
51-
<developer_name>Cassidy James Blaede</developer_name>
85+
5286
<url type="homepage">https://cassidyjames.com</url>
5387
<url type="bugtracker">https://github.com/cassidyjames/butler/issues</url>
88+
<url type="vcs-browser">https://github.com/cassidyjames/butler</url>
5489
<url type="donation">https://cassidyjames.com/pay</url>
5590
<url type="help">https://cassidyjames.com/support</url>
5691
</component>

data/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@define-color headerbar_bg_color #03A9F5;
1+
@define-color headerbar_bg_color #03a9f5;
22
@define-color headerbar_fg_color #fff;
33
@define-color headerbar_border_color #fff;
4-
@define-color headerbar_backdrop_color mix(@headerbar_bg_color, @window_bg_color, 0.2);
4+
@define-color headerbar_backdrop_color mix(@headerbar_bg_color, @window_bg_color, 0.1);
55

66
@define-color accent_color @headerbar_bg_color;

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(
22
'com.cassidyjames.butler',
33
'vala', 'c',
4-
version: '1.0.0'
4+
version: '1.0.1'
55
)
66

77
gnome = import('gnome')

src/MainWindow.vala

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
*/
55

66
public class Butler.MainWindow : Adw.ApplicationWindow {
7+
public Adw.Toast fullscreen_toast;
8+
public Adw.ToastOverlay toast_overlay;
9+
public Gtk.Revealer header_revealer;
10+
711
private const GLib.ActionEntry[] ACTION_ENTRIES = {
812
{ "toggle_fullscreen", toggle_fullscreen },
913
{ "set_server", on_set_server_activate },
@@ -26,12 +30,15 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
2630
}
2731

2832
construct {
33+
maximized = App.settings.get_boolean ("window-maximized");
34+
fullscreened = App.settings.get_boolean ("window-fullscreened");
35+
2936
var site_menu = new Menu ();
3037
site_menu.append (_("_Log Out…"), "win.log_out");
3138

3239
var app_menu = new Menu ();
3340
// TODO: How do I add shortcuts to the menu?
34-
app_menu.append (_("Toggle _Fullscreen"), "win.toggle_fullscreen");
41+
app_menu.append (_("_Fullscreen"), "win.toggle_fullscreen");
3542
app_menu.append (_("Change _Server…"), "win.set_server");
3643
app_menu.append (_("_About %s").printf (App.NAME), "win.about");
3744

@@ -48,6 +55,16 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
4855
var header = new Adw.HeaderBar ();
4956
header.pack_end (menu_button);
5057

58+
header_revealer = new Gtk.Revealer () {
59+
child = header,
60+
reveal_child = !fullscreened
61+
};
62+
63+
fullscreen_toast = new Adw.Toast ("Press <b>Ctrl F</b> or <b>F11</b> to toggle fullscreen") {
64+
action_name = "win.toggle_fullscreen",
65+
button_label = _("Exit _Fullscreen")
66+
};
67+
5168
web_view = new Butler.WebView ();
5269

5370
string server = App.settings.get_string ("server");
@@ -73,11 +90,15 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
7390
stack.add_named (status_page, "loading");
7491
stack.add_named (web_view, "web");
7592

93+
toast_overlay = new Adw.ToastOverlay () {
94+
child = stack
95+
};
96+
7697
var grid = new Gtk.Grid () {
7798
orientation = Gtk.Orientation.VERTICAL
7899
};
79-
grid.attach (header, 0, 0);
80-
grid.attach (stack, 0, 1);
100+
grid.attach (header_revealer, 0, 0);
101+
grid.attach (toast_overlay, 0, 1);
81102

82103
set_content (grid);
83104

@@ -86,14 +107,11 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
86107

87108
set_default_size (window_width, window_height);
88109

89-
if (App.settings.get_boolean ("window-maximized")) {
90-
maximize ();
91-
}
92-
93110
close_request.connect (() => {
94111
save_window_state ();
95112
return Gdk.EVENT_PROPAGATE;
96113
});
114+
notify["fullscreened"].connect (save_window_state);
97115
notify["maximized"].connect (save_window_state);
98116

99117
web_view.load_changed.connect ((load_event) => {
@@ -111,9 +129,12 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
111129
}
112130

113131
private void save_window_state () {
114-
if (maximized) {
132+
if (fullscreened) {
133+
App.settings.set_boolean ("window-fullscreened", true);
134+
} else if (maximized) {
115135
App.settings.set_boolean ("window-maximized", true);
116136
} else {
137+
App.settings.set_boolean ("window-fullscreened", false);
117138
App.settings.set_boolean ("window-maximized", false);
118139
App.settings.set (
119140
"window-size", "(ii)",
@@ -178,8 +199,12 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
178199
public void toggle_fullscreen () {
179200
if (fullscreened) {
180201
unfullscreen ();
202+
header_revealer.set_reveal_child (true);
203+
fullscreen_toast.dismiss ();
181204
} else {
182205
fullscreen ();
206+
header_revealer.set_reveal_child (false);
207+
toast_overlay.add_toast (fullscreen_toast);
183208
}
184209
}
185210

@@ -202,12 +227,12 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
202227
default_response = "save",
203228
extra_child = server_entry,
204229
};
205-
server_dialog.add_response ("close", "Cancel");
230+
server_dialog.add_response ("close", "_Cancel");
206231

207-
server_dialog.add_response ("demo", _("Reset to Demo"));
232+
server_dialog.add_response ("demo", _("_Reset to Demo"));
208233
server_dialog.set_response_appearance ("demo", Adw.ResponseAppearance.DESTRUCTIVE);
209234

210-
server_dialog.add_response ("save", _("Set Server"));
235+
server_dialog.add_response ("save", _("_Set Server"));
211236
server_dialog.set_response_appearance ("save", Adw.ResponseAppearance.SUGGESTED);
212237

213238
server_dialog.present ();
@@ -243,8 +268,8 @@ public class Butler.MainWindow : Adw.ApplicationWindow {
243268
body_use_markup = true,
244269
default_response = "log_out"
245270
};
246-
log_out_dialog.add_response ("close", "Stay Logged In");
247-
log_out_dialog.add_response ("log_out", _("Log Out"));
271+
log_out_dialog.add_response ("close", "_Stay Logged In");
272+
log_out_dialog.add_response ("log_out", _("_Log Out"));
248273
log_out_dialog.set_response_appearance ("log_out", Adw.ResponseAppearance.DESTRUCTIVE);
249274

250275
log_out_dialog.present ();

src/Widgets/WebView.vala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ public class Butler.WebView : WebKit.WebView {
3030
hardware_acceleration_policy = WebKit.HardwareAccelerationPolicy.ALWAYS
3131
};
3232

33+
var custom_css = new WebKit.UserStyleSheet (
34+
"""
35+
header,
36+
.header {
37+
app-region: drag;
38+
-webkit-app-region: drag;
39+
}
40+
""",
41+
WebKit.UserContentInjectedFrames.TOP_FRAME,
42+
WebKit.UserStyleLevel.AUTHOR,
43+
null,
44+
null
45+
);
46+
user_content_manager.add_style_sheet (custom_css);
47+
3348
settings = webkit_settings;
3449
web_context = new WebKit.WebContext ();
3550

0 commit comments

Comments
 (0)