Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview / demo mode & CSS documentation #30

Open
takase1121 opened this issue Jun 9, 2023 · 6 comments · May be fixed by #71
Open

Preview / demo mode & CSS documentation #30

takase1121 opened this issue Jun 9, 2023 · 6 comments · May be fixed by #71
Labels
enhancement New feature or request

Comments

@takase1121
Copy link

takase1121 commented Jun 9, 2023

Since I can't run regreet without greetd, it's hard to run regreet with GTK_DEBUG=inspector and poke around to see what can be customized. Adding a demo mode would really help.

I realized that this program needs layer shell. Even if the inspector is started, I cannot interact with it (that's the whole point!). Are there extra documentation on how to theme regreet in CSS?

@rharish101
Copy link
Owner

rharish101 commented Jun 9, 2023

Since I can't run regreet without greetd, it's hard to run regreet with GTK_DEBUG=inspector and poke around to see what can be customized. Adding a demo mode would really help.

Good idea, a demo mode would also help in development. I guess I can try to somehow mock greetd in the codebase with the demo mode.

I realized that this program needs layer shell.

Could you tell me why? Is it because the inspector doesn't work with it, or is it because it would also provide more features?

Are there extra documentation on how to theme regreet in CSS?

Not really, I didn't make any, since it's just like any other GTK app. If you want to see the GTK structure, just see src/gui/templates.rs. Specifically, these lines:

/// Main UI of the greeter
#[relm4::widget_template(pub)]
impl WidgetTemplate for Ui {
view! {
gtk::Overlay {
/// Background image
#[name = "background"]
gtk::Picture,
/// Main login box
add_overlay = &gtk::Frame {
set_halign: gtk::Align::Center,
set_valign: gtk::Align::Center,
inline_css: "background-color: @theme_bg_color",
gtk::Grid {
set_column_spacing: 15,
set_margin_bottom: 15,
set_margin_end: 15,
set_margin_start: 15,
set_margin_top: 15,
set_row_spacing: 15,
set_width_request: 500,
/// Widget to display messages to the user
#[name = "message_label"]
attach[0, 0, 3, 1] = &gtk::Label {
set_margin_bottom: 15,
// Format all messages in boldface.
#[wrap(Some)]
set_attributes = &gtk::pango::AttrList {
insert: {
let mut font_desc = gtk::pango::FontDescription::new();
font_desc.set_weight(gtk::pango::Weight::Bold);
gtk::pango::AttrFontDesc::new(&font_desc)
},
},
},
#[template]
attach[0, 1, 1, 1] = &EntryLabel {
set_label: "User:",
set_height_request: 45,
},
/// Label for the sessions widget
#[name = "session_label"]
#[template]
attach[0, 2, 1, 1] = &EntryLabel {
set_label: "Session:",
set_height_request: 45,
},
/// Widget containing the usernames
#[name = "usernames_box"]
attach[1, 1, 1, 1] = &gtk::ComboBoxText { set_hexpand: true },
/// Widget where the user enters the username
#[name = "username_entry"]
attach[1, 1, 1, 1] = &gtk::Entry { set_hexpand: true },
/// Widget containing the sessions
#[name = "sessions_box"]
attach[1, 2, 1, 1] = &gtk::ComboBoxText,
/// Widget where the user enters the session
#[name = "session_entry"]
attach[1, 2, 1, 1] = &gtk::Entry,
/// Label for the password widget
#[name = "input_label"]
#[template]
attach[0, 2, 1, 1] = &EntryLabel {
set_height_request: 45,
},
/// Widget where the user enters a secret
#[name = "secret_entry"]
attach[1, 2, 1, 1] = &gtk::PasswordEntry { set_show_peek_icon: true },
/// Widget where the user enters something visible
#[name = "visible_entry"]
attach[1, 2, 1, 1] = &gtk::Entry,
/// Button to toggle manual user entry
#[name = "user_toggle"]
attach[2, 1, 1, 1] = &gtk::ToggleButton {
set_icon_name: "document-edit-symbolic",
set_tooltip_text: Some("Manually enter username"),
},
/// Button to toggle manual session entry
#[name = "sess_toggle"]
attach[2, 2, 1, 1] = &gtk::ToggleButton {
set_icon_name: "document-edit-symbolic",
set_tooltip_text: Some("Manually enter session command"),
},
/// Collection of action buttons (eg. Login)
attach[1, 3, 2, 1] = &gtk::Box {
set_halign: gtk::Align::End,
set_spacing: 15,
/// Button to cancel password entry
#[name = "cancel_button"]
gtk::Button {
set_focusable: true,
set_label: "Cancel",
},
/// Button to enter the password and login
#[name = "login_button"]
gtk::Button {
set_focusable: true,
set_label: "Login",
set_receives_default: true,
add_css_class: "suggested-action",
},
},
},
},
/// Clock widget
add_overlay = &gtk::Frame {
set_halign: gtk::Align::Center,
set_valign: gtk::Align::Start,
// Make it fit cleanly onto the top edge of the screen.
inline_css: "
border-top-right-radius: 0px;
border-top-left-radius: 0px;
border-top-width: 0px;
background-color: @theme_bg_color;
",
/// Label displaying the current date & time
#[name = "datetime_label"]
gtk::Label { set_width_request: 150 },
},
/// Collection of widgets appearing at the bottom
add_overlay = &gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_halign: gtk::Align::Center,
set_valign: gtk::Align::End,
set_margin_bottom: 15,
set_spacing: 15,
gtk::Frame {
/// Notification bar for error messages
#[name = "error_info"]
gtk::InfoBar {
// During init, the info bar closing animation is shown. To hide that, make
// it invisible. Later, the code will permanently make it visible, so that
// `InfoBar::set_revealed` will work properly with animations.
set_visible: false,
set_message_type: gtk::MessageType::Error,
/// The actual error message
#[name = "error_label"]
gtk::Label {
set_halign: gtk::Align::Center,
set_margin_top: 10,
set_margin_bottom: 10,
set_margin_start: 10,
set_margin_end: 10,
},
}
},
/// Collection of buttons that close the greeter (eg. Reboot)
gtk::Box {
set_halign: gtk::Align::Center,
set_homogeneous: true,
set_spacing: 15,
/// Button to reboot
#[name = "reboot_button"]
#[template]
EndButton { set_label: "Reboot" },
/// Button to power-off
#[name = "poweroff_button"]
#[template]
EndButton { set_label: "Power Off" },
},
},
}
}
}

@rharish101 rharish101 added the enhancement New feature or request label Jun 9, 2023
@takase1121
Copy link
Author

Could you tell me why? Is it because the inspector doesn't work with it, or is it because it would also provide more features?

Sorry, I didn't meant it like this - regreet would stay on top of the inspector so one can't use it.
I assume the demo mode would allow regreet to run as a normal window, so it can be moved around.

@rharish101
Copy link
Owner

Sorry, I didn't meant it like this - regreet would stay on top of the inspector so one can't use it. I assume the demo mode would allow regreet to run as a normal window, so it can be moved around.

Ah, so you mean that the demo mode should "disable" layer shell? Well, ReGreet doesn't use layer shell; it's just a normal window that's fullscreen.

I develop ReGreet on an X11 desktop (although Wayland might also work, but I haven't tested it) by running it through the command line. It spawns a fullscreen window, which I can reduce to a normal window using my window manager. Then I can access the inspector.

The demo mode I'm thinking of should allow one to use all ReGreet features - like showing the list of (dummy) usernames/sessions, enter (dummy) passwords, etc. - without actually contacting greetd.

@takase1121
Copy link
Author

Ah, so you mean that the demo mode should "disable" layer shell? Well, ReGreet doesn't use layer shell; it's just a normal window that's fullscreen.

Oh, didn't know!

I develop ReGreet on an X11 desktop (although Wayland might also work, but I haven't tested it) by running it through the command line. It spawns a fullscreen window, which I can reduce to a normal window using my window manager. Then I can access the inspector.

How do you connect to greetd when running as another user? I've been trying to figure this out.

@rharish101
Copy link
Owner

How do you connect to greetd when running as another user? I've been trying to figure this out.

I just run ReGreet as the greeter user using sudo, as follows:

sudo -Eu greeter regreet

The -E switch is to allow passing environment variables. Here, it's needed to get the greetd IPC socket.

@exoess
Copy link

exoess commented Jun 6, 2024

sudo -Eu greeter regreet

tried this, just got

panicked at 'called `Result::unwrap()` on an `Err` value: BoolError { message: "Failed to initialize GTK", filename: "/build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gtk4-0.5.5/src/rt.rs", function: "gtk4::rt", line: 153 }', /build/.cargo/registry/src/index.crates.io-6f17d22bba15001f/relm4-0.5.0/src/lib.rs:110:17

@rtgiskard rtgiskard linked a pull request Jun 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants