Skip to content

Commit

Permalink
add gh-cli option + fix yaru-purple-dark (#46)
Browse files Browse the repository at this point in the history
* Add: github-cli-deb option

Add an option for github-cli-deb, this is a preliminary test.

* fix: Syntax errors

* fix: Syntax error on 122

Lol more syntax errors

* fix nesting

* put things in correct order

* shrink text so no scrollbar

* attempt to workaround pacstall

* 83% chance of going to hell for this one

* also default to dark

* likewise force purple

* fmt

* fmt again

* newline is the new sexy

---------

Co-authored-by: ajstrongdev <[email protected]>
  • Loading branch information
oklopfer and ajstrongdev authored Jul 9, 2023
1 parent e2450b8 commit d94fc07
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/org.rhinolinux.RhinoSetup.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<summary>Window maximized state</summary>
</key>
<key name="gtk-theme" type="s">
<default>'Yaru-purple'</default>
<default>'Yaru-purple-dark'</default>
<summary>Gtk+ Theme</summary>
</key>
</schema>
Expand Down
39 changes: 38 additions & 1 deletion src/extra_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::COMMANDS;
pub(crate) struct ExtraSettingsModel {
remove_nala: bool,
enable_apport: bool,
enable_github: bool,
}

#[derive(Debug)]
Expand All @@ -16,6 +17,8 @@ pub(crate) enum ExtraSettingsInput {
Nala(bool),
/// Represents the Apport switch state
Apport(bool),
// Represents the GitHub switch state
Github(bool),
}

#[derive(Debug)]
Expand Down Expand Up @@ -68,9 +71,21 @@ impl SimpleComponent for ExtraSettingsModel {
}
}
},
adw::ActionRow {
set_title: "GitHub CLI",
set_subtitle: &gettext("GitHub on the command-line."),

add_suffix = &gtk::Switch {
set_valign: gtk::Align::Center,

connect_active_notify[sender] => move |switch| {
sender.input(Self::Input::Github(switch.is_active()));
}
}
},
adw::ActionRow {
set_title: "Apport",
set_subtitle: &gettext("Apport is a crash reporting system that helps us improve the stability of the system."),
set_subtitle: &gettext("A crash reporting system, improving the stability of your system."),

add_suffix = &gtk::Switch {
set_valign: gtk::Align::Center,
Expand Down Expand Up @@ -103,6 +118,7 @@ impl SimpleComponent for ExtraSettingsModel {
let model = ExtraSettingsModel {
remove_nala: false,
enable_apport: false,
enable_github: false,
};

let widgets = view_output!();
Expand All @@ -124,6 +140,18 @@ impl SimpleComponent for ExtraSettingsModel {

self.remove_nala = !switched_on;
},
Self::Input::Github(switched_on) => {
tracing::info!(
"{}",
if switched_on {
"Enabling Github"
} else {
"Disabling Github"
}
);

self.enable_github = switched_on;
},
Self::Input::Apport(switched_on) => {
tracing::info!(
"{}",
Expand All @@ -149,6 +177,15 @@ impl SimpleComponent for ExtraSettingsModel {
commands.push("systemctl enable apport.service || true");
}

if self.enable_github {
commands.push("echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers");
commands.push(
"HOME=/home/$USER runuser -l $USER -c 'SUDO_USER=$USER \
PACSTALL_DOWNLOADER=quiet-wget pacstall -PI github-cli-deb'",
);
commands.push("sudo sed -i 's/%sudo ALL=(ALL) NOPASSWD:ALL//' /etc/sudoers");
}

COMMANDS.write_inner().insert("extra_settings", commands);
}
}
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ fn main() {
// HACK: The app doesn't start up with the "correct" theme, this "hack" "fixes"
// it.
if config::PROFILE != "Devel" {
if let Err(error) =
gio::Settings::new("org.gnome.desktop.interface").set_string("gtk-theme", "Yaru-purple")
if let Err(error) = gio::Settings::new("org.gnome.desktop.interface")
.set_string("gtk-theme", "Yaru-purple-dark")
{
tracing::error!("Error FORCING GTK theme: {error}");
}
Expand Down

0 comments on commit d94fc07

Please sign in to comment.