Desktop file parsing improvements
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -40,6 +40,15 @@ dependencies = [
|
|||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "0.7.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aliasable"
|
name = "aliasable"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
@@ -1537,6 +1546,7 @@ dependencies = [
|
|||||||
"manifest-dir-macros",
|
"manifest-dir-macros",
|
||||||
"mint",
|
"mint",
|
||||||
"nix 0.26.1",
|
"nix 0.26.1",
|
||||||
|
"regex",
|
||||||
"resvg",
|
"resvg",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"stardust-xr-fusion",
|
"stardust-xr-fusion",
|
||||||
@@ -1679,6 +1689,8 @@ version = "1.7.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
|
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ linicon = "2.3.0"
|
|||||||
manifest-dir-macros = "0.1.16"
|
manifest-dir-macros = "0.1.16"
|
||||||
mint = "0.5.9"
|
mint = "0.5.9"
|
||||||
nix = "0.26.1"
|
nix = "0.26.1"
|
||||||
|
regex = "1.7.1"
|
||||||
resvg = "0.29.0"
|
resvg = "0.29.0"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
stardust-xr-fusion = "0.38.1"
|
stardust-xr-fusion = "0.38.1"
|
||||||
@@ -28,4 +29,4 @@ ustr = "0.9.0"
|
|||||||
walkdir = "2.3.2"
|
walkdir = "2.3.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use color_eyre::eyre::{eyre, Result};
|
|||||||
use glam::Quat;
|
use glam::Quat;
|
||||||
use mint::Vector3;
|
use mint::Vector3;
|
||||||
use nix::unistd::setsid;
|
use nix::unistd::setsid;
|
||||||
|
use regex::Regex;
|
||||||
use stardust_xr_fusion::{
|
use stardust_xr_fusion::{
|
||||||
client::{Client, FrameInfo, RootHandler},
|
client::{Client, FrameInfo, RootHandler},
|
||||||
core::values::Transform,
|
core::values::Transform,
|
||||||
@@ -174,7 +175,7 @@ impl RootHandler for ProtoStar {
|
|||||||
let scale = grabbabe_move.move_by(info.delta);
|
let scale = grabbabe_move.move_by(info.delta);
|
||||||
self.grabbable
|
self.grabbable
|
||||||
.content_parent()
|
.content_parent()
|
||||||
.set_position(None, [self.position.x*scale, self.position.y*scale, self.position.z*scale])
|
.set_position(Some(self.client.get_root()), [self.position.x*scale, self.position.y*scale, self.position.z*scale])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
if grabbabe_move.final_value() == 0.0001 {
|
if grabbabe_move.final_value() == 0.0001 {
|
||||||
@@ -237,9 +238,9 @@ impl RootHandler for ProtoStar {
|
|||||||
.get_position_rotation_scale(self.client.get_root())
|
.get_position_rotation_scale(self.client.get_root())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let executable = dbg!(self.execute_command.clone());
|
let executable = self.execute_command.clone();
|
||||||
|
|
||||||
//TODO: split the executable string for the args
|
//TODO: split the executable string for the args
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
let distance_vector = distance_future.await.ok().unwrap().0;
|
let distance_vector = distance_future.await.ok().unwrap().0;
|
||||||
let distance =
|
let distance =
|
||||||
@@ -248,9 +249,12 @@ impl RootHandler for ProtoStar {
|
|||||||
let future = startup_settings.generate_startup_token().unwrap();
|
let future = startup_settings.generate_startup_token().unwrap();
|
||||||
|
|
||||||
std::env::set_var("STARDUST_STARTUP_TOKEN", future.await.unwrap());
|
std::env::set_var("STARDUST_STARTUP_TOKEN", future.await.unwrap());
|
||||||
|
let re = Regex::new(r"%[fFuUdDnNickvm]").unwrap();
|
||||||
|
let exec = re.replace_all(&executable, "");
|
||||||
|
let mut executable_array : Vec<&str> = dbg!(exec.split_whitespace().collect());
|
||||||
unsafe {
|
unsafe {
|
||||||
Command::new(executable)
|
Command::new(executable_array.remove(0))
|
||||||
|
.args(executable_array)
|
||||||
.stdin(Stdio::null())
|
.stdin(Stdio::null())
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
|
|||||||
14
src/xdg.rs
14
src/xdg.rs
@@ -12,7 +12,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
use regex::Regex;
|
||||||
fn get_data_dirs() -> Vec<PathBuf> {
|
fn get_data_dirs() -> Vec<PathBuf> {
|
||||||
let xdg_data_dirs_str = std::env::var("XDG_DATA_DIRS").unwrap_or_default();
|
let xdg_data_dirs_str = std::env::var("XDG_DATA_DIRS").unwrap_or_default();
|
||||||
|
|
||||||
@@ -88,9 +88,13 @@ pub fn parse_desktop_file(path: PathBuf) -> Result<DesktopFile, String> {
|
|||||||
let mut categories = Vec::new();
|
let mut categories = Vec::new();
|
||||||
let mut icon = None;
|
let mut icon = None;
|
||||||
let mut no_display = false;
|
let mut no_display = false;
|
||||||
|
let mut desktop_entry_found = false;
|
||||||
|
|
||||||
|
let re = Regex::new(r"^\[([^\]]*)\]$").unwrap();
|
||||||
|
|
||||||
// Loop through each line of the file
|
// Loop through each line of the file
|
||||||
for line in reader.lines() {
|
for line in reader.lines() {
|
||||||
|
|
||||||
let line = match line {
|
let line = match line {
|
||||||
Ok(line) => line,
|
Ok(line) => line,
|
||||||
Err(err) => return Err(format!("Failed to read line: {}", err)),
|
Err(err) => return Err(format!("Failed to read line: {}", err)),
|
||||||
@@ -101,6 +105,14 @@ pub fn parse_desktop_file(path: PathBuf) -> Result<DesktopFile, String> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(captures) = re.captures(&line){
|
||||||
|
let entry = captures.get(1).unwrap();
|
||||||
|
desktop_entry_found = entry.as_str().contains("Desktop Entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
if !desktop_entry_found {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Split the line into a key-value pair by looking for the first "=" character
|
// Split the line into a key-value pair by looking for the first "=" character
|
||||||
let parts = line.split_once('=');
|
let parts = line.split_once('=');
|
||||||
let (key, value) = match parts {
|
let (key, value) = match parts {
|
||||||
|
|||||||
Reference in New Issue
Block a user