1
0
Fork 0

fix term to use st always

This commit is contained in:
Malte Brandy 2018-06-01 02:02:23 +02:00
parent ffe24b9016
commit a95ea647e0
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
3 changed files with 21 additions and 15 deletions

View file

@ -4,15 +4,15 @@ extern crate task_hookrs;
extern crate error_chain;
use std::rc::Rc;
use rust_scripts::hotkeys::{run, term, holdterm, menu, main_loop, Next};
use rust_scripts::hotkeys::{run, term, menu, main_loop, Next};
use rust_scripts::kassandra::{kassandra, change_state, new_tasks};
use rust_scripts::error::Result;
quick_main!(|| -> Result<()> {
let w17menu = {
let summer = holdterm("Summer", "ssh summer@door.w17.io");
let lock = holdterm("Lock", "ssh close@door.w17.io");
let unlock = holdterm("Unlock", "ssh open@door.w17.io");
let summer = term("Summer", "ssh summer@door.w17.io");
let lock = term("Lock", "ssh close@door.w17.io");
let unlock = term("Unlock", "ssh open@door.w17.io");
let mpd_whisky = term("MPD Whisky", "ncmpcpp -h whisky");
let hub = run("Hub", "firefox --new-window https://hub.w17.io");
let kitchen = run("Kitchen", "firefox --new-window http://kitchen.w17.io");
@ -67,7 +67,7 @@ quick_main!(|| -> Result<()> {
menu(
"Accounting",
vec![
holdterm("Jali", "jali -l ."),
term("Jali", "jali -l ."),
run(
"Beschlüsse",
"firefox --new-window https://git.darmstadt.ccc.de/vorstand/beschluesse/raw/master/beschl%C3%BCsse"
@ -95,10 +95,10 @@ quick_main!(|| -> Result<()> {
);
let monitor = term("Monitor", "htop");
let wifi = term("WLAN", "nmtui");
let update_home = holdterm("Update Home", "home-manager switch");
let update_sys = holdterm("Update Sys", "sudo nixos-rebuild switch");
let gc = holdterm("Collect Garbage", "nix-collect-garbage -d");
let optimise = holdterm("Optimise", "nix optimise-store");
let update_home = term("Update Home", "home-manager switch");
let update_sys = term("Update Sys", "sudo nixos-rebuild switch");
let gc = term("Collect Garbage", "nix-collect-garbage -d");
let optimise = term("Optimise", "nix optimise-store");
menu(
"Maintenance",
vec![
@ -119,6 +119,7 @@ quick_main!(|| -> Result<()> {
("kiva", "brandy@kiva-forward"),
("ag", "brandy@ag-forward"),
("whisky", "whisky"),
("kitchen", "kitchen"),
("vorstand", "vorstand"),
("shells", "shells"),
("charon", "charon"),

View file

@ -4,6 +4,7 @@ use dialog::errors::{Error, ErrorKind as EK};
use dialog::rofi::RofiDialogProvider;
use std::process::Command as StdCommand;
use std::os::unix::process::CommandExt;
use std::env::var;
use error::{Result, ResultExt};
use hotkeys::Next::*;
@ -19,12 +20,16 @@ pub fn run<T: Into<String>>(name: T, command: &str) -> Item {
)
}
pub fn term<T: Into<String>>(name: T, command: &str) -> Item {
run(name, &format!("urxvt -e {}", command))
pub fn term_cmd(command: &str) -> String {
format!(
"{} -e {}",
var("TERMINAL").unwrap_or("urxvt".into()),
command
)
}
pub fn holdterm<T: Into<String>>(name: T, command: &str) -> Item {
run(name, &format!("urxvt -hold -e {}", command))
pub fn term<T: Into<String>>(name: T, command: &str) -> Item {
run(name, &term_cmd(command))
}
pub fn menu<T: Into<String>>(name: T, options: Vec<Item>) -> Item {

View file

@ -16,7 +16,7 @@ use dialog::errors::ErrorKind as DEK;
use update::update_tasks;
use generate::GeneratedTask;
use error::{Result, ResultExt, ErrorKind as EK, Error};
use hotkeys::str2cmd;
use hotkeys::{str2cmd, term_cmd};
use tasktree::{TreeCache, TaskNode};
fn print_task_short(task: &Task) -> String {
@ -707,7 +707,7 @@ What's the progress?",
})
.len() > 0
{
str2cmd("urxvt -e sh -c")
str2cmd(&term_cmd("sh -c"))
.arg("jali -l. && task gen_id:'Aktualisiere Buchhaltung' done")
.output()?;
}