rharish101 / ReGreet

Clean and customizable greeter for greetd
GNU General Public License v3.0
430 stars 19 forks source link

Background image not showing #68

Open hidraulicChicken opened 7 months ago

hidraulicChicken commented 7 months ago

Hey folks, I'm on NixOS 23.11 with sway and tried everything to get the background showing, but never ever shows up. Here are my configs: /etc/greetd/regreet.toml

[GTK]
application_prefer_dark_theme = true
cursor_theme_name = "Adwaita"
font_name = "JetBrainsMonoNerdFontMono-Regular"
icon_theme_name = "Adwaita"
theme_name = "Adwaita"

[background]
path = "/tmp/fallout_loading.jpg"

[commands]
poweroff = ["systemctl", "poweroff"]
reboot = ["systemctl", "reboot"] 
swayConfig = pkgs.writeText "greetd-sway-config" ''
    # `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet.
    exec "${pkgs.greetd.regreet}/bin/regreet -l debug  &> /tmp/regreet.log; swaymsg exit"
    bindsym Mod4+shift+e exec swaynag \
    -t warning \
    -m 'What do you want to do?' \
    -b 'Poweroff' 'systemctl poweroff' \
    -b 'Reboot' 'systemctl reboot'
    include /home/gergoe/.config/sway/config
  '';

greetd command: dbus-run-session ${pkgs.sway}/bin/sway --config ${swayConfig}

regreet.log

background: -rwxrwxrwx 1 myuser users 275K 2024-04-30 14:02 /tmp/fallout_loading.jpg

Sadly the I couldn't decipher the error message: Gtk-WARNING **: 14:27:41.009: Theme parser warning: :6:17-18: Empty declaration

Please let me know what else I could check/set.

rtgiskard commented 5 months ago

the error message seems to be caused by the inline_css in the code, can be ignored at the time.

hidraulicChicken commented 4 months ago

Ok, thanks for the input, but the problem still remains, no background. Additionally the keyboard layout is different from the one set in sway.

rharish101 commented 3 months ago

Your background path seems to be in /tmp. Are you sure that the image exists there? Could you also try with a different path?

hidraulicChicken commented 3 months ago

tried it on multitude of paths, with multiple owners and 777 permissions, none worked. is there a way to debug this?

On Sat, Aug 3, 2024, 13:09 Harish Rajagopal @.***> wrote:

Your background path seems to be in /tmp. Are you sure that the image exists there? Could you also try with a different path?

— Reply to this email directly, view it on GitHub https://github.com/rharish101/ReGreet/issues/68#issuecomment-2266678331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH6ZMGT5JFXWETSUVUAUH3ZPS25JAVCNFSM6AAAAABHAIYB4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRWGY3TQMZTGE . You are receiving this because you authored the thread.Message ID: @.***>

rharish101 commented 3 months ago

Well, in the codebase, I just pass the path to GTK, and it should automatically pick it up. I'll try to write a minimal GTK app for displaying an image, and then you can see if it works.

hidraulicChicken commented 3 months ago

that would be helpful, I'll look for some GTK related debug options, maybe I can log stuff out

On Sat, Aug 3, 2024, 13:34 Harish Rajagopal @.***> wrote:

Well, in the codebase, I just pass the path to GTK, and it should automatically pick it up. I'll try to write a minimal GTK app for displaying an image, and then you can see if it works.

— Reply to this email directly, view it on GitHub https://github.com/rharish101/ReGreet/issues/68#issuecomment-2266683836, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH6ZMA7IJBZLRE3OO3DUO3ZPS53XAVCNFSM6AAAAABHAIYB4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRWGY4DGOBTGY . You are receiving this because you authored the thread.Message ID: @.***>

rharish101 commented 3 months ago

Can you run this file:

use gtk::glib::clone;
use gtk::prelude::{BoxExt, ButtonExt, GtkWindowExt};
use relm4::{gtk, ComponentParts, ComponentSender, RelmApp, RelmWidgetExt, SimpleComponent};

struct AppModel {
    counter: u8,
}

#[derive(Debug)]
enum AppInput {
    Increment,
    Decrement,
}

struct AppWidgets {
    label: gtk::Label,
}

impl SimpleComponent for AppModel {
    /// The type of the messages that this component can receive.
    type Input = AppInput;
    /// The type of the messages that this component can send.
    type Output = ();
    /// The type of data with which this component will be initialized.
    type Init = u8;
    /// The root GTK widget that this component will create.
    type Root = gtk::Window;
    /// A data structure that contains the widgets that you will need to update.
    type Widgets = AppWidgets;

    fn init_root() -> Self::Root {
        gtk::Window::builder()
            .title("Simple app")
            .default_width(300)
            .default_height(100)
            .build()
    }

    /// Initialize the UI and model.
    fn init(
        counter: Self::Init,
        window: &Self::Root,
        sender: ComponentSender<Self>,
    ) -> relm4::ComponentParts<Self> {
        let model = AppModel { counter };

        let vbox = gtk::Box::builder()
            .orientation(gtk::Orientation::Vertical)
            .spacing(5)
            .build();

        let inc_button = gtk::Button::with_label("Increment");
        let dec_button = gtk::Button::with_label("Decrement");

        let label = gtk::Label::new(Some(&format!("Counter: {}", model.counter)));
        label.set_margin_all(5);

        let mut args = std::env::args();
        args.next();
        let picture = gtk::Picture::for_filename(args.next().unwrap());

        window.set_child(Some(&vbox));
        vbox.set_margin_all(5);
        vbox.append(&inc_button);
        vbox.append(&dec_button);
        vbox.append(&label);
        vbox.append(&picture);

        inc_button.connect_clicked(clone!(@strong sender => move |_| {
            sender.input(AppInput::Increment);
        }));

        dec_button.connect_clicked(clone!(@strong sender => move |_| {
            sender.input(AppInput::Decrement);
        }));

        let widgets = AppWidgets { label };

        ComponentParts { model, widgets }
    }

    fn update(&mut self, message: Self::Input, _sender: ComponentSender<Self>) {
        match message {
            AppInput::Increment => {
                self.counter = self.counter.wrapping_add(1);
            }
            AppInput::Decrement => {
                self.counter = self.counter.wrapping_sub(1);
            }
        }
    }

    /// Update the view to represent the updated model.
    fn update_view(&self, widgets: &mut Self::Widgets, _sender: ComponentSender<Self>) {
        widgets
            .label
            .set_label(&format!("Counter: {}", self.counter));
    }
}

fn main() {
    let app = RelmApp::new("relm4.test.simple_manual");
    app.run::<AppModel>(0);
}

All you have to do is:

  1. Install Rust.
  2. Create a directory, say, dummy.
  3. Enter this directory and run cargo init.
  4. Add dependencies: cargo add relm4@0.5 gtk4@0.5.
  5. Replace src/main.rs with the above code.
  6. Run cargo run /path/to/your/image.jpg, using the path to any image.

See if you can see your image in this example GTK app.