Skip to content

Commit 669932d

Browse files
committed
feat: add Flatpak setup dialog and enhance permissions handling; update version to 1.4.4
1 parent cb82092 commit 669932d

File tree

14 files changed

+276
-120
lines changed

14 files changed

+276
-120
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
[submodule "arch"]
66
path = arch
77
url = https://aur.archlinux.org/luminance.git
8+
[submodule "flathub"]
9+
path = flathub
10+
url = git@github.com:flathub/com.sidevesh.Luminance.git

Makefile

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all release debug install uninstall install-debug uninstall-debug clean package-deb package-rpm package-arch package-arch-test install-arch uninstall-arch flatpak install-flatpak uninstall-flatpak lint-flatpak run-flatpak flatpak-bundle pack-gnome-extension install-gnome-extension uninstall-gnome-extension
1+
.PHONY: all release debug install uninstall install-debug uninstall-debug package-deb package-rpm package-arch package-arch-test install-arch uninstall-arch flatpak flatpak-bundle install-flatpak uninstall-flatpak run-flatpak package-flatpak-flathub lint-flatpak-flathub package-gnome-extension install-gnome-extension uninstall-gnome-extension clean
22

33
# Build directories
44
BUILD_RELEASE_DIR = build/release
@@ -13,7 +13,7 @@ RPMBUILD_DIR = $(RPM_DIR)/rpmbuild
1313
OUTPUTS_DIR = $(PKG_DIR)/outputs
1414
FLATPAK_DIR = $(PKG_DIR)/flatpak
1515
FLATPAK_REPO_DIR = $(FLATPAK_DIR)/repo
16-
FLATPAK_MANIFEST = $(CURDIR)/packaging/flatpak/com.sidevesh.Luminance.yml
16+
FLATPAK_MANIFEST_IN = $(CURDIR)/packaging/flatpak/com.sidevesh.Luminance.yml.in
1717
FLATPAK_APP_ID = com.sidevesh.Luminance
1818

1919
VERSION = $(shell cat version.txt)
@@ -124,12 +124,13 @@ uninstall-arch:
124124
@echo "Uninstalling Arch package..."
125125
sudo pacman -R luminance
126126

127-
flatpak:
127+
flatpak: $(FLATPAK_MANIFEST_IN)
128128
@echo "Building Flatpak..."
129129
mkdir -p $(FLATPAK_DIR)
130-
# Copy manifest to build directory to satisfy flatpak-builder output requirements
131-
# This is necessary because flatpak-builder forbids 'path' from pointing outside the manifest directory
132-
cp $(FLATPAK_MANIFEST) $(CURDIR)/.flatpak-manifest.yml
130+
# Generate manifest for local build directly to .flatpak-manifest.yml
131+
sed -e "s|@LUMINANCE_SOURCE_TYPE@|dir|g" \
132+
-e "s|@LUMINANCE_SOURCE_DETAILS@|path: $(CURDIR)|g" \
133+
$(FLATPAK_MANIFEST_IN) > $(CURDIR)/.flatpak-manifest.yml
133134

134135
# Run flathub-build from root. This creates 'repo' and 'builddir' in $(CURDIR)
135136
flatpak run --filesystem=$(CURDIR) --command=flathub-build org.flatpak.Builder --force-clean $(CURDIR)/.flatpak-manifest.yml
@@ -140,6 +141,12 @@ flatpak:
140141
mv builddir $(FLATPAK_DIR)/
141142
rm $(CURDIR)/.flatpak-manifest.yml
142143

144+
flatpak-bundle: flatpak
145+
@echo "Creating Flatpak bundle..."
146+
mkdir -p $(OUTPUTS_DIR)
147+
flatpak build-bundle $(FLATPAK_REPO_DIR) $(OUTPUTS_DIR)/$(FLATPAK_APP_ID).flatpak $(FLATPAK_APP_ID)
148+
@echo "Flatpak bundle created at $(OUTPUTS_DIR)/$(FLATPAK_APP_ID).flatpak"
149+
143150
install-flatpak: flatpak
144151
@echo "Installing Flatpak..."
145152
flatpak remote-add --user --if-not-exists --no-gpg-verify luminance-local-repo $(CURDIR)/$(FLATPAK_REPO_DIR)
@@ -150,38 +157,28 @@ uninstall-flatpak:
150157
-flatpak uninstall --user -y $(FLATPAK_APP_ID)
151158
-flatpak remote-delete --user luminance-local-repo
152159

153-
lint-flatpak: flatpak
154-
@echo "Linting Flatpak manifest..."
155-
# Lint the original manifest
156-
-flatpak run --filesystem=$(CURDIR) --command=flatpak-builder-lint org.flatpak.Builder manifest $(FLATPAK_MANIFEST)
157-
@echo "Linting Flatpak repo..."
158-
@if [ -d "$(FLATPAK_REPO_DIR)" ]; then \
159-
flatpak run --filesystem=$(CURDIR) --command=flatpak-builder-lint org.flatpak.Builder repo $(CURDIR)/$(FLATPAK_REPO_DIR); \
160-
else \
161-
echo "Repo directory not found. Skipping repo linting (run 'make flatpak-build' first)."; \
162-
fi
163-
164160
run-flatpak: install-flatpak
165161
@echo "Running Flatpak with GDB..."
166162
flatpak run --devel --command=sh $(FLATPAK_APP_ID) -c "gdb -batch -ex run -ex \"bt full\" --args /app/bin/$(FLATPAK_APP_ID)"
167163

168-
flatpak-bundle: flatpak
169-
@echo "Creating Flatpak bundle..."
170-
mkdir -p $(OUTPUTS_DIR)
171-
flatpak build-bundle $(FLATPAK_REPO_DIR) $(OUTPUTS_DIR)/$(FLATPAK_APP_ID).flatpak $(FLATPAK_APP_ID)
172-
@echo "Flatpak bundle created at $(OUTPUTS_DIR)/$(FLATPAK_APP_ID).flatpak"
164+
package-flatpak-flathub: $(FLATPAK_MANIFEST_IN) version.txt
165+
@echo "Updating flathub manifest..."
166+
sed -e "s|@LUMINANCE_SOURCE_TYPE@|git|g" \
167+
-e "s|@LUMINANCE_SOURCE_DETAILS@|url: https://github.com/sidevesh/Luminance.git\n tag: $(VERSION)|g" \
168+
$(FLATPAK_MANIFEST_IN) > flathub/com.sidevesh.Luminance.yml
173169

174-
# Remove build directories
175-
clean:
176-
rm -rf build
170+
lint-flatpak-flathub: package-flatpak-flathub
171+
@echo "Linting Flatpak manifest..."
172+
# Lint the manifest generated for flathub
173+
-flatpak run --filesystem=$(CURDIR) --command=flatpak-builder-lint org.flatpak.Builder manifest flathub/com.sidevesh.Luminance.yml
177174

178175
# GNOME Extension
179176
EXTENSION_UUID = luminance-extension@sidevesh
180177
SRC_EXTENSION_DIR = gnome-extension/$(EXTENSION_UUID)
181178
EXTENSION_BUILD_DIR = $(PKG_DIR)/gnome-extension
182179
EXTENSION_ZIP = $(OUTPUTS_DIR)/$(EXTENSION_UUID).shell-extension.zip
183180

184-
pack-gnome-extension:
181+
package-gnome-extension:
185182
@echo "Packing GNOME extension..."
186183
rm -rf $(EXTENSION_BUILD_DIR)
187184
mkdir -p $(EXTENSION_BUILD_DIR)
@@ -190,7 +187,7 @@ pack-gnome-extension:
190187
gnome-extensions pack $(EXTENSION_BUILD_DIR) --force --out-dir=$(OUTPUTS_DIR)
191188
@echo "Extension packed at $(EXTENSION_ZIP)"
192189

193-
install-gnome-extension: pack-gnome-extension
190+
install-gnome-extension: package-gnome-extension
194191
@echo "Installing GNOME extension..."
195192
gnome-extensions install --force $(EXTENSION_ZIP)
196193
@echo "GNOME extension installed. You may need to enable it with: gnome-extensions enable $(EXTENSION_UUID)"
@@ -200,3 +197,6 @@ uninstall-gnome-extension:
200197
@echo "Uninstalling GNOME extension..."
201198
-gnome-extensions uninstall $(EXTENSION_UUID)
202199
@echo "Extension uninstalled."
200+
201+
clean:
202+
rm -rf build

arch

Submodule arch updated from e5debb8 to 59074ad

flathub

Submodule flathub added at 945a495

install_files/com.sidevesh.Luminance.metainfo.xml.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<image type="source">https://raw.githubusercontent.com/sidevesh/Luminance/main/screenshots/screenshot.dark.png</image>
2727
</screenshot>
2828
</screenshots>
29+
<branding>
30+
<color type="primary" scheme_preference="light">#70b0ff</color>
31+
<color type="primary" scheme_preference="dark">#144785</color>
32+
</branding>
2933
<releases>
3034
@RELEASES@
3135
</releases>

packaging/flatpak/com.sidevesh.Luminance.yml renamed to packaging/flatpak/com.sidevesh.Luminance.yml.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ finish-args:
77
- --socket=fallback-x11
88
- --socket=wayland
99
- --device=all
10+
- --filesystem=/sys
1011
- --system-talk-name=org.freedesktop.UPower
1112
- --share=ipc
1213
modules:
@@ -36,5 +37,5 @@ modules:
3637
- --buildtype=release
3738
- -Dinstall_udev_rules=false
3839
sources:
39-
- type: dir
40-
path: .
40+
- type: @LUMINANCE_SOURCE_TYPE@
41+
@LUMINANCE_SOURCE_DETAILS@

releases.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<release version="1.4.4" date="2026-02-16"/>
12
<release version="1.4.3" date="2026-02-13"/>
23
<release version="1.4.2" date="2026-02-03"/>
34
<release version="1.4.1" date="2026-02-03"/>

scripts/flatpak-setup.sh

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ verify() {
7777
BACKLIGHT_COUNT=$(ls /sys/class/backlight/ | wc -l)
7878
if [ "$BACKLIGHT_COUNT" -gt 0 ]; then
7979
echo -e "[${GREEN}OK${NC}] Found $BACKLIGHT_COUNT backlight interfaces in /sys/class/backlight/"
80+
81+
# Check for actual write permissions
82+
CAN_WRITE=0
83+
for backlight in /sys/class/backlight/*; do
84+
if [ -w "$backlight/brightness" ]; then
85+
echo -e "[${GREEN}OK${NC}] Write permission available for $(basename "$backlight")"
86+
CAN_WRITE=1
87+
else
88+
echo -e "[${RED}FAIL${NC}] No write permission for $(basename "$backlight")/brightness. (Current user: $(whoami))"
89+
fi
90+
done
8091
else
8192
echo -e "[${YELLOW}INFO${NC}] No internal backlight interfaces found (normal for desktops)"
8293
fi
@@ -89,15 +100,40 @@ verify() {
89100
exit 0
90101
}
91102

92-
# Check for uninstall flag
93-
if [ "$1" == "--uninstall" ]; then
94-
uninstall
95-
fi
103+
# Function to show help
104+
show_help() {
105+
echo "Usage: $(basename "$0") [OPTION]"
106+
echo "Setup permissions for Luminance Flatpak to control monitors."
107+
echo ""
108+
echo "Options:"
109+
echo " --verify Verify the installation and permissions"
110+
echo " --uninstall Uninstall the setup and revert changes"
111+
echo " --help Show this help message"
112+
echo ""
113+
echo "If no option is provided, the setup will be performed."
114+
exit 0
115+
}
96116

97-
# Check for verify flag
98-
if [ "$1" == "--verify" ]; then
99-
verify
100-
fi
117+
# Parse arguments
118+
case "$1" in
119+
--uninstall)
120+
uninstall
121+
;;
122+
--verify)
123+
verify
124+
;;
125+
--help|-h)
126+
show_help
127+
;;
128+
"")
129+
# Proceed with setup
130+
;;
131+
*)
132+
echo "Error: Unknown option '$1'"
133+
echo "Try '$(basename "$0") --help' for more information."
134+
exit 1
135+
;;
136+
esac
101137

102138
echo "Starting setup for Luminance..."
103139

@@ -155,6 +191,15 @@ if [ "$STEAMOS" = 1 ] ; then
155191
fi
156192
fi
157193

194+
# Check if user is in video group
195+
if groups "$USER" | grep &>/dev/null '\bvideo\b'; then
196+
echo "User $USER is already in the video group."
197+
else
198+
echo "Adding user $USER to the video group..."
199+
sudo usermod -aG video "$USER"
200+
echo "PLEASE NOTE: You may need to log out and log back in for group changes to take effect."
201+
fi
202+
158203
echo "Setup complete!"
159204
echo "To verify the installation, run this script with the --verify flag."
160205
echo "./flatpak-setup.sh --verify"

src/states/displays.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ char* get_display_name(guint index) {
219219
GlobalDisplayIndex display_index = _display_indexes[index];
220220
if (display_index.type == DISPLAY_TYPE_INTERNAL_BACKLIGHT) {
221221
if (_internal_backlight_display_directories_count == 1) {
222-
return "Built-in display";
222+
return "Built-in Display";
223223
}
224224
gchar *display_name = malloc(256);
225-
snprintf(display_name, 256, "Built-in display %d", display_index.index + 1);
225+
snprintf(display_name, 256, "Built-in Display %d", display_index.index + 1);
226226
return display_name;
227227
} else {
228228
ddcbc_display* display = _get_ddcbc_display(index);
@@ -286,7 +286,7 @@ void set_display_brightness_percentage(guint index, gdouble brightness_percentag
286286
if (emit_osd_signal) {
287287
gchar model_name[256];
288288
if (display_index.type == DISPLAY_TYPE_INTERNAL_BACKLIGHT) {
289-
snprintf(model_name, sizeof(model_name), "Built-in display");
289+
snprintf(model_name, sizeof(model_name), "Built-in Display");
290290
} else {
291291
ddcbc_display* display = _get_ddcbc_display(index);
292292
if (display)
@@ -298,4 +298,24 @@ void set_display_brightness_percentage(guint index, gdouble brightness_percentag
298298
}
299299
}
300300

301+
gboolean have_internal_displays_without_permission_in_flatpak() {
302+
if (is_running_in_flatpak() == FALSE) {
303+
return FALSE;
304+
}
305+
306+
if (_internal_backlight_display_directories_count == 0) {
307+
return FALSE;
308+
}
309+
310+
for (guint i = 0; i < _internal_backlight_display_directories_count; i++) {
311+
gchar brightness_file_path[256];
312+
snprintf(brightness_file_path, sizeof(brightness_file_path), "/sys/class/backlight/%s/brightness", _internal_backlight_display_directories[i]);
313+
if (access(brightness_file_path, W_OK) != 0) {
314+
return TRUE;
315+
}
316+
}
317+
318+
return FALSE;
319+
}
320+
301321
#endif
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#ifndef UI_COMPONENTS_FLATPAK_SETUP_DIALOG_C
2+
#define UI_COMPONENTS_FLATPAK_SETUP_DIALOG_C
3+
4+
#include <gtk/gtk.h>
5+
#include <adwaita.h>
6+
#include "../../constants/main.c"
7+
8+
void show_flatpak_setup_dialog(GtkWindow *parent_window) {
9+
GtkWidget *dialog;
10+
GtkWidget *main_box;
11+
GtkWidget *header;
12+
GtkWidget *content_box;
13+
GtkWidget *intro_label;
14+
GtkWidget *step1_label;
15+
GtkWidget *link_button;
16+
GtkWidget *step2_label;
17+
GtkWidget *step3_label;
18+
GtkWidget *command_label;
19+
GtkCssProvider *css_provider;
20+
21+
dialog = gtk_window_new();
22+
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
23+
if (parent_window) {
24+
gtk_window_set_transient_for(GTK_WINDOW(dialog), parent_window);
25+
}
26+
gtk_window_set_title(GTK_WINDOW(dialog), "Flatpak Setup");
27+
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
28+
gtk_window_set_default_size(GTK_WINDOW(dialog), 450, -1);
29+
30+
main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
31+
gtk_window_set_child(GTK_WINDOW(dialog), main_box);
32+
33+
header = adw_header_bar_new();
34+
gtk_widget_add_css_class(header, "flat");
35+
gtk_window_set_titlebar(GTK_WINDOW(dialog), header);
36+
37+
// CSS for the command well
38+
css_provider = gtk_css_provider_new();
39+
gtk_css_provider_load_from_string(css_provider,
40+
".command-well { background-color: alpha(currentColor, 0.08); border-radius: 6px; padding: 6px 12px; }");
41+
gtk_style_context_add_provider_for_display(gdk_display_get_default(),
42+
GTK_STYLE_PROVIDER(css_provider),
43+
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
44+
45+
content_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
46+
gtk_widget_set_margin_top(content_box, 24);
47+
gtk_widget_set_margin_bottom(content_box, 24);
48+
gtk_widget_set_margin_start(content_box, 24);
49+
gtk_widget_set_margin_end(content_box, 24);
50+
gtk_box_append(GTK_BOX(main_box), content_box);
51+
52+
// Intro
53+
intro_label = gtk_label_new("To control monitors from a Flatpak app, you need to grant permissions on your host system.");
54+
gtk_label_set_wrap(GTK_LABEL(intro_label), TRUE);
55+
gtk_label_set_xalign(GTK_LABEL(intro_label), 0);
56+
gtk_box_append(GTK_BOX(content_box), intro_label);
57+
58+
// Step 1
59+
step1_label = gtk_label_new(NULL);
60+
gtk_label_set_markup(GTK_LABEL(step1_label), "<b>1.</b> Download the setup script below:");
61+
gtk_label_set_xalign(GTK_LABEL(step1_label), 0);
62+
gtk_box_append(GTK_BOX(content_box), step1_label);
63+
64+
link_button = gtk_link_button_new_with_label(APP_INFO_FLATPAK_SETUP_SCRIPT_URL, "Download Setup Script");
65+
gtk_widget_set_halign(link_button, GTK_ALIGN_START);
66+
gtk_box_append(GTK_BOX(content_box), link_button);
67+
68+
// Step 2
69+
step2_label = gtk_label_new(NULL);
70+
gtk_label_set_markup(GTK_LABEL(step2_label), "<b>2.</b> Allow the file to be executed (Properties > Permissions > Allow executing file as program).");
71+
gtk_label_set_wrap(GTK_LABEL(step2_label), TRUE);
72+
gtk_label_set_xalign(GTK_LABEL(step2_label), 0);
73+
gtk_box_append(GTK_BOX(content_box), step2_label);
74+
75+
// Step 3
76+
step3_label = gtk_label_new(NULL);
77+
gtk_label_set_markup(GTK_LABEL(step3_label), "<b>3.</b> Run the script (double-click or run from terminal).");
78+
gtk_label_set_wrap(GTK_LABEL(step3_label), TRUE);
79+
gtk_label_set_xalign(GTK_LABEL(step3_label), 0);
80+
gtk_box_append(GTK_BOX(content_box), step3_label);
81+
82+
command_label = gtk_label_new(NULL);
83+
gtk_label_set_markup(GTK_LABEL(command_label), "<b>4.</b> Restart this app for changes to take effect.");
84+
gtk_label_set_xalign(GTK_LABEL(command_label), 0);
85+
gtk_box_append(GTK_BOX(content_box), command_label);
86+
87+
gtk_window_present(GTK_WINDOW(dialog));
88+
}
89+
90+
#endif

0 commit comments

Comments
 (0)