ferrix_app/utils.rs
1/* styles.rs
2 *
3 * Copyright 2025 Michail Krasnov <mskrasnov07@ya.ru>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21//! Utilities and helper functions
22
23use anyhow::Result;
24use std::{
25 env,
26 path::{Path, PathBuf},
27 process::Command,
28};
29
30pub fn xdg_open<O: ToString>(object: O) -> Result<()> {
31 Command::new("/usr/bin/xdg-open")
32 .arg(object.to_string())
33 .spawn()?;
34 Ok(())
35}
36
37pub fn get_home() -> PathBuf {
38 let home_env = env::var("HOME").unwrap_or("/tmp".to_string());
39
40 Path::new(&home_env).to_path_buf()
41}