Added example and did some work
This commit is contained in:
parent
031c6076f1
commit
f1249c90c7
4 changed files with 108 additions and 9 deletions
40
example.nua
Normal file
40
example.nua
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
tiling {
|
||||||
|
tiling_factor = 180;
|
||||||
|
}
|
||||||
|
keybinds {
|
||||||
|
$act = meta;
|
||||||
|
|
||||||
|
select_left = $act+left;
|
||||||
|
select_right = $act+right;
|
||||||
|
select_down = $act+down;
|
||||||
|
select_up = $act+up;
|
||||||
|
# or:
|
||||||
|
#select_all = $act+arrow;
|
||||||
|
|
||||||
|
# valid general keysets:
|
||||||
|
# arrow number letter 1strow
|
||||||
|
# 2ndrow 3rdrow mod symbol
|
||||||
|
# function special
|
||||||
|
# you can also add the prefix
|
||||||
|
# "non" to the start of any
|
||||||
|
# keyset to get any key except
|
||||||
|
# that keyset. keyset special
|
||||||
|
# is keys including modifiers,
|
||||||
|
# backspace, tab, enter
|
||||||
|
|
||||||
|
expand_all = $act+shift+arrow;
|
||||||
|
|
||||||
|
move_all = $act+alt+arrow;
|
||||||
|
|
||||||
|
select_workspace_all = $act+W+arrow;
|
||||||
|
|
||||||
|
move_workspace_all = $act+W+alt+arrow;
|
||||||
|
|
||||||
|
bookmark_workspace_all = $act+B+shift+number;
|
||||||
|
|
||||||
|
jump_workspace_all = $act+B+number;
|
||||||
|
}
|
||||||
|
|
||||||
|
include = file2.nua;
|
||||||
|
|
||||||
|
env = WINDOW_MANAGER=nuarth;
|
24
src/config.rs
Normal file
24
src/config.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//! Config parsing.
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
/// Gets Nuarth's config directory.
|
||||||
|
fn get_config_dir() -> PathBuf {
|
||||||
|
let env = std::env::var("XDG_CONFIG_HOME");
|
||||||
|
if let Ok(env) = env {
|
||||||
|
return PathBuf::from(env).join("nuarth");
|
||||||
|
}
|
||||||
|
#[allow(deprecated, clippy::unwrap_used)]
|
||||||
|
std::env::home_dir().unwrap().join(".config").join("nuarth")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configuration for tiling.
|
||||||
|
pub struct TilingConfig {
|
||||||
|
/// The tiling factor used to calculate how many tiles in a screen.
|
||||||
|
pub tiling_factor: f64
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Nuarth configuration.
|
||||||
|
pub struct Config {
|
||||||
|
pub tiling: TilingConfig
|
||||||
|
}
|
24
src/main.rs
24
src/main.rs
|
@ -1,29 +1,35 @@
|
||||||
//! The main code for Nuarth.
|
//! The main code for Nuarth.
|
||||||
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
|
#![warn(missing_docs, clippy::missing_docs_in_private_items, clippy::unwrap_used)]
|
||||||
|
|
||||||
use polling::{Event, Poller};
|
use polling::{Event, Poller};
|
||||||
|
|
||||||
/// The state of Nuarth.
|
mod state;
|
||||||
struct State {}
|
mod config;
|
||||||
|
|
||||||
|
use state::DelegationState;
|
||||||
fn main() {
|
fn main() {
|
||||||
let display = wayland_server::Display::<State>::new();
|
let display = wayland_server::Display::<DelegationState>::new();
|
||||||
if display.is_err() {
|
if display.is_err() {
|
||||||
println!("[FATAL] Cannot load libwayland-server.so, exiting.");
|
println!("[FATAL] Cannot load libwayland-server.so, exiting.");
|
||||||
println!("[HINT] Compile Nuarth with wayland_server's dlopen feature disabled\n[HINT] to not require this library");
|
println!("[HINT] Compile Nuarth with wayland_server's dlopen feature disabled\n[HINT] to not require this library");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
let mut display = display.unwrap(); // Error state is checked above
|
|
||||||
|
#[allow(clippy::unwrap_used)] // Error state checked above
|
||||||
|
let mut display = display.unwrap();
|
||||||
|
|
||||||
let polling_fd = display.backend().poll_fd();
|
let polling_fd = display.backend().poll_fd();
|
||||||
let poller = Poller::new().unwrap(); // At the moment, this method cannot return an error.
|
|
||||||
unsafe { poller.add(&polling_fd, Event::readable(0)).unwrap(); } // At the moment, this method cannot return an error.
|
let poller = Poller::new().expect("failed to create poller for polling file descriptor");
|
||||||
|
|
||||||
|
unsafe { poller.add(&polling_fd, Event::readable(0)).expect("failed to initalize polling file descriptor"); }
|
||||||
|
|
||||||
let mut events = polling::Events::new();
|
let mut events = polling::Events::new();
|
||||||
|
|
||||||
loop { // Event loop
|
loop { // Event loop
|
||||||
events.clear();
|
events.clear();
|
||||||
poller.wait(&mut events, None).unwrap(); // At the moment, this method cannot return an error.
|
poller.wait(&mut events, None).expect("failed waiting for wayland events");
|
||||||
display.dispatch_clients(&mut State { }).unwrap(); // At the moment, this method cannot return an error.
|
|
||||||
|
display.dispatch_clients(&mut DelegationState { }).expect("failed to dispatch event handlers for clients");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
29
src/state.rs
Normal file
29
src/state.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//! Stuff related to state and dispatch methods.
|
||||||
|
|
||||||
|
use wayland_server::{Dispatch, protocol::*};
|
||||||
|
|
||||||
|
/// The state of Nuarth.
|
||||||
|
pub struct DelegationState {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The state of Nuarth for a client.
|
||||||
|
struct ClientState {}
|
||||||
|
|
||||||
|
impl Dispatch<wl_output::WlOutput, ClientState, DelegationState> for DelegationState {
|
||||||
|
fn request(
|
||||||
|
state: &mut DelegationState,
|
||||||
|
client: &wayland_server::Client,
|
||||||
|
resource: &wl_output::WlOutput,
|
||||||
|
request: <wl_output::WlOutput as wayland_server::Resource>::Request,
|
||||||
|
data: &ClientState,
|
||||||
|
dhandle: &wayland_server::DisplayHandle,
|
||||||
|
data_init: &mut wayland_server::DataInit<'_, DelegationState>,
|
||||||
|
) {
|
||||||
|
if let wl_output::Request::Release = request {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
println!("[ERROR] Unknown wl_output request!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue