Skip to content

Commit

Permalink
keyboard: create keyboard.conf in hyprland if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Jun 13, 2024
1 parent 1fb3060 commit 5680332
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions keyboard_plugin/src/backend/hyprland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use re_set_lib::ERROR;
#[cfg(debug_assertions)]
use re_set_lib::{utils::macros::ErrorLevel, write_log_to_file};

use crate::r#const::HYPRLAND_DEFAULT_FILE;
use crate::keyboard_layout::KeyboardLayout;
use crate::r#const::HYPRLAND_DEFAULT_FILE;
use crate::utils::{get_default_path, parse_setting};

pub fn get_saved_layouts_hyprland(all_keyboards: &[KeyboardLayout]) -> Vec<KeyboardLayout> {
Expand Down Expand Up @@ -64,21 +64,24 @@ pub fn write_to_config_hyprland(layouts: &[KeyboardLayout]) {
} else {
get_default_path()
})
}
}

let mut input_config = if let Some(path) = path {
OpenOptions::new()
.write(true)
.read(true)
.open(PathBuf::from(path))
.expect("Failed to open file")
OpenOptions::new()
.write(true)
.read(true)
.create(true)
.truncate(true)
.open(PathBuf::from(path))
.expect("Failed to open file")
} else {
OpenOptions::new()
.write(true)
.read(true)
.open(HYPRLAND_DEFAULT_FILE.clone())
.expect("Failed to open file")

OpenOptions::new()
.write(true)
.read(true)
.create(true)
.truncate(true)
.open(HYPRLAND_DEFAULT_FILE.clone())
.expect("Failed to open file")
};

let mut layout_string = String::new();
Expand Down

0 comments on commit 5680332

Please sign in to comment.