1
0
Fork 0

Add weechet and hera

This commit is contained in:
Malte Brandy 2018-06-09 11:40:49 +02:00
parent 3fc85de877
commit 0bd3b5c406
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
4 changed files with 50 additions and 16 deletions

View file

@ -4,7 +4,7 @@ extern crate task_hookrs;
extern crate error_chain;
use std::rc::Rc;
use rust_scripts::hotkeys::{run, term, menu, main_loop, Next};
use rust_scripts::hotkeys::{run, run_cmd, term, menu, main_loop, Next};
use rust_scripts::kassandra::{kassandra, change_state, new_tasks};
use rust_scripts::error::Result;
@ -53,6 +53,17 @@ quick_main!(|| -> Result<()> {
"Messaging",
vec![
run("Mails", "evolution"),
run_cmd(
"Weechat",
vec![
"st".into(),
"-e".into(),
"ssh".into(),
"-t".into(),
"hera".into(),
"tmux -L weechat attach".into(),
]
),
run("Riot", "firefox --new-window https://riot.im/app"),
run("WhatsApp", "firefox --new-window https://web.whatsapp.com"),
run("Telegram", "telegram-desktop"),
@ -91,6 +102,7 @@ quick_main!(|| -> Result<()> {
vec![
run("neo", "setxkbmap de neo"),
run("qwertz", "setxkbmap de"),
run("qwerty", "setxkbmap us"),
],
);
let monitor = term("Monitor", "htop");
@ -122,6 +134,7 @@ quick_main!(|| -> Result<()> {
("kitchen", "kitchen"),
("vorstand", "vorstand"),
("shells", "shells"),
("hera", "hera"),
("charon", "charon"),
].into_iter()
.map(|(name, login)| term(name, &format!("ssh {}", login)))

View file

@ -20,6 +20,17 @@ pub fn run<T: Into<String>>(name: T, command: &str) -> Item {
)
}
pub fn run_cmd<T: Into<String>>(name: T, command: Command) -> Item {
(
name.into(),
Do(Rc::new(move || {
mk_cmd(command.clone()).exec();
Ok(Exit)
})),
)
}
pub fn term_cmd(command: &str) -> String {
format!(
"{} -e {}",

View file

@ -78,11 +78,22 @@ enum Location {
Anywhere,
}
#[derive(Copy, Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
enum MPD {
#[serde(rename = "apollo")]
Apollo,
#[serde(rename = "whisky")]
Whisky,
#[serde(rename = "kitchen")]
Kitchen,
}
#[derive(Copy, Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
struct State {
mode: Mode,
location: Location,
connectivity: Connectivity,
mpd: MPD,
}
fn task_blocked(cache: &TaskCache, task: &Task) -> bool {
@ -126,17 +137,19 @@ fn get_state() -> Result<State> {
s.push(".kassandra_state");
s
};
Ok(if let Ok(state_file) = File::open(&state_path) {
from_reader(state_file)?
} else {
let state = State {
mode: Mode::Orga,
connectivity: Connectivity::Online,
location: Location::Anywhere,
};
save_state(&state)?;
state
})
if let Ok(state_file) = File::open(&state_path) {
if let Ok(state) = from_reader(state_file) {
return Ok(state);
}
}
let state = State {
mode: Mode::Orga,
connectivity: Connectivity::Online,
location: Location::Anywhere,
mpd: MPD::Apollo,
};
save_state(&state)?;
Ok(state)
}
fn enter_new_task<T: DialogProvider, S: Into<String>>(dialog: &mut T, msg: S) -> Result<Task> {

View file

@ -74,10 +74,7 @@ pub fn update_tasks(cache: &mut TaskCache) -> Result<()> {
"Sortiere Inbox Auslandskoordination",
"Sortiere Inbox Kiva",
"Update nixos apollo",
"Update home apollo",
"Update home fb4",
"Update home hera",
"Update home charon",
"Update home hephaistos",
"Klavier üben",
]),
daily(),