Skip to content

Commit

Permalink
Merge pull request #4 from leb-kuchen/category-refactor
Browse files Browse the repository at this point in the history
Category refactor / Add config option
  • Loading branch information
leb-kuchen authored Mar 26, 2024
2 parents b292e68 + 6162667 commit cf224db
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 148 deletions.
29 changes: 28 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cosmic-applet-apps-menu"
version = "0.1.4"
version = "0.1.5"
edition = "2021"

[dependencies]
Expand All @@ -24,3 +24,6 @@ freedesktop-desktop-entry = "0.5.1"
unicode-segmentation = "1.11.0"
notify = "6.1.1"
tokio = "1.36.0"
paste = "1.0.14"
lexical-sort = "0.3.1"
unicode-display-width = "0.3.0"
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,35 @@ cd cosmic-applet-apps-menu
cargo b -r
sudo just install
```

# Config

The configuration directory is `.config/cosmic/dev.dominiccgeh.CosmicAppletAppsMenu/`.

Each configuration option coresponds to a filename, e.g. you can set `skip_empty_categories` with `true > .config/cosmic/dev.dominiccgeh.CosmicAppletAppsMenu/skip_empty_categories`.

These are the default options:

```
skip_empty_categories: true,
categories: [
"Favorites",
"Audio",
"AudioVideo",
"COSMIC",
"Education",
"Game",
"Graphics",
"Network",
"Office",
"Science",
"Settings",
"System",
"Utility",
"Other",
],
sort_categories: true,
```

Note that, categories are case-sensitive and `Favorites` and `Other` are not
acutally categories in your desktop files.
29 changes: 27 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
use std::vec;

use cosmic::cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry};

use serde::{Deserialize, Serialize};
pub const CONFIG_VERSION: u64 = 1;

#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Config {}
pub struct Config {
pub skip_empty_categories: bool,
pub categories: Vec<String>,
pub sort_categories: bool,
}

impl Default for Config {
fn default() -> Self {
Self {}
Self {
skip_empty_categories: true,
categories: vec![
"Favorites".into(),
"Audio".into(),
"AudioVideo".into(),
"COSMIC".into(),
"Education".into(),
"Game".into(),
"Graphics".into(),
"Network".into(),
"Office".into(),
"Science".into(),
"Settings".into(),
"System".into(),
"Utility".into(),
"Other".into(),
],
sort_categories: true,
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

use crate::window::Window;

use config::{AppListConfig, Config, CONFIG_VERSION};
Expand Down
Loading

0 comments on commit cf224db

Please sign in to comment.