mirror of
https://github.com/Wojtek242/rwmstatus.git
synced 2024-11-21 15:15:25 +01:00
Initial commit
This commit is contained in:
commit
ed816fa7ad
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
**/*.rs.bk
|
30
Cargo.lock
generated
Normal file
30
Cargo.lock
generated
Normal file
@ -0,0 +1,30 @@
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rwmstatus"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11"
|
||||
version = "2.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74"
|
||||
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
|
||||
"checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235"
|
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "rwmstatus"
|
||||
version = "0.1.0"
|
||||
authors = ["Wojciech Kozlowski <wk@wojciechkozlowski.eu>"]
|
||||
|
||||
links = "X11"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
x11 = "2"
|
4
build.rs
Normal file
4
build.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-lib=X11");
|
||||
println!("cargo:rustc-link-search=native=/usr/X11R6/lib");
|
||||
}
|
35
src/main.rs
Normal file
35
src/main.rs
Normal file
@ -0,0 +1,35 @@
|
||||
extern crate x11;
|
||||
|
||||
use x11::xlib::Display;
|
||||
use x11::xlib::{XDefaultRootWindow, XOpenDisplay, XStoreName, XSync};
|
||||
|
||||
use std::ptr;
|
||||
use std::process;
|
||||
use std::thread;
|
||||
use std::time;
|
||||
|
||||
use std::ffi::CString;
|
||||
|
||||
fn main() {
|
||||
let display: *mut Display;
|
||||
|
||||
unsafe {
|
||||
display = XOpenDisplay(ptr::null());
|
||||
}
|
||||
|
||||
if display == ptr::null_mut() {
|
||||
eprintln!("rwmstatus: cannot open display.");
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
loop {
|
||||
let status = CString::new("Hello!").expect("CString::new failed when setting status.");
|
||||
|
||||
unsafe {
|
||||
XStoreName(display, XDefaultRootWindow(display), status.as_ptr());
|
||||
XSync(display, false as i32);
|
||||
}
|
||||
|
||||
thread::sleep(time::Duration::from_secs(1));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user