Skip to content

Commit

Permalink
list subcommand, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
justjokiing committed Jan 7, 2025
1 parent 3042560 commit 3800ad7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 61 deletions.
56 changes: 20 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ This creates necessary configuration and systemd files in your user directory.

kshift uses a YAML configuration file, created during `install` and located at `~/.config/kshift/kshift.yml`. Below is a guide to setting up and customizing your configuration.

Use the command `kshift conf` to open the configuration file in your default editor. Load and confirm this configuration by running `kshift`

### Default Configuration

```yaml
Expand Down Expand Up @@ -91,14 +93,14 @@ All global parameters are optional; if not provided, they will use the default v

All parameters are optional, but to enable automatic theme switching, a `time` variable must be specified.

| Parameter | Description | Example Value |
| -------------- | --------------------------------------------------- | ------------------------ |
| `colorscheme` | Name of the Plasma color scheme | `BreezeLight` |
| `icontheme` | Name of the icon theme | `Papirus-Dark` |
| `wallpaper` | Path to the wallpaper image | `~/Pictures/morning.jpg` |
| `desktoptheme` | Name of the Plasma desktop theme | `Breeze` |
| `command` | Custom command to execute when the theme is applied | `echo 'Theme applied'` |
| `time` | Schedule for theme activation | `sunrise` or `HH:MM` |
| Parameter | Description | Example Value |
| -------------- | --------------------------------------------------- | --------------------------------- |
| `colorscheme` | Name of the Plasma color scheme | `BreezeLight` |
| `icontheme` | Name of the icon theme | `Papirus-Dark` |
| `wallpaper` | Path to the wallpaper image | `~/Pictures/morning.jpg` |
| `desktoptheme` | Name of the Plasma desktop theme | `Breeze` |
| `command` | Custom command to execute when the theme is applied | `echo 'Theme applied'` |
| `time` | Schedule for theme activation | `sunset`, `HH:MM`, `weekly` |


## Usage
Expand All @@ -118,37 +120,19 @@ Run `kshift` with various options:
- `status`: Display the current status of kshift and active timers.
- `config`: Open the kshift configuration file in the default editor for editing.
- `logs`: View the most recent entries from the kshift log file.
- `list`: List possible themes or attributes

### Examples
| **Command** | **Description** |
|--------------------------------------------|------------------------------------------------------------------|
| `kshift theme night` | Apply a theme by name. |
| `kshift` | Have kshift determine the current theme and apply it. |
| `kshift status` | Check current status. |
| `kshift theme night -c BreezeLight -w ~/cat.png` | Apply a theme with modifications. |
| `kshift theme -w ~/cat.png` | Apply a theme attribute with no theme. |
| `kshift list themes` | List available kshift themes |
| `kshift list colorschemes` | List available colorschemes |

- Apply a theme by name:

```bash
kshift theme night
```
- Have kshift determine the current theme and apply it:

```bash
kshift
```

- Check current status:

```bash
kshift status
```

- Apply a theme with modification:

```bash
kshift theme night -c BreezeLight -w ~/cat.png
```

- Apply a theme attribute with no theme:

```bash
kshift theme -w ~/cat.png
```

## Systemd Integration

Expand Down
53 changes: 28 additions & 25 deletions src/kshift/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from string import Template

from kshift.utils import open_in_default_editor
import kshift.utils

c = load_config()

Expand Down Expand Up @@ -276,7 +276,7 @@ def status():
@cli.command(help="Edit the kshift configuration file")
def config():
"""Edit the configuration file."""
open_in_default_editor(c.config_loc)
kshift.utils.open_in_default_editor(c.config_loc)


@cli.command(help="Tail on kshift logs")
Expand All @@ -298,17 +298,37 @@ def logs(all):
print(line, end="")


@cli.command(help="List possible themes or attributes")
@click.argument("attribute",
type=click.Choice(
["themes", "colorschemes", "iconthemes", "desktopthemes"],
case_sensitive=False))
def list(attribute):
if attribute == "themes":
print("Available themes:")
for name, theme_config in c.themes.items():
print(f"- {name}")
elif attribute == "colorschemes":
print("Available colorschemes:")
for colorscheme in kshift.utils.get_colorschemes():
print(f"- {colorscheme}")
elif attribute == "iconthemes":
print("Available icon themes:")
for icontheme in kshift.utils.get_iconthemes():
print(f"- {icontheme}")
elif attribute == "desktopthemes":
print("Available desktop themes:")
for desktop_theme in kshift.utils.get_desktopthemes():
print(f"- {desktop_theme}")


@cli.command(help="Change themes or apply specific theme elements")
@click.argument("theme",
type=str,
required=False,
default=None,
nargs=1,
metavar="[THEME_NAME]")
@click.option("--list",
"list_themes",
is_flag=True,
help="List all available themes.")
@click.option(
"-c",
"--colorscheme",
Expand All @@ -333,22 +353,7 @@ def logs(all):
type=str,
help="Set a specific desktop theme (overrides theme)",
)
def theme(theme, list_themes, colorscheme, icontheme, wallpaper,
desktop_theme):
"""Apply a theme or specific theme elements.
THEME_NAME is optional and can be passed as a positional argument.
"""
if list_themes:
# Ensure `--list` is mutually exclusive with other options/arguments
if theme or any([colorscheme, icontheme, wallpaper, desktop_theme]):
raise click.UsageError(
"--list cannot be used with other options or arguments.")
# List all available themes
print("Available themes:")
for name, theme_config in c.themes.items():
print(f"- {name}")
return
def theme(theme, colorscheme, icontheme, wallpaper, desktop_theme):

kshift_status = subprocess.run(
"systemctl --user is-enabled kshift-startup.timer".split(),
Expand Down Expand Up @@ -376,9 +381,7 @@ def theme(theme, list_themes, colorscheme, icontheme, wallpaper,

# If there were no arguments
# Determine which theme should be active, then shift to it
if not any(
[theme, list_themes, colorscheme, icontheme, wallpaper, desktop_theme
]):
if not any([theme, colorscheme, icontheme, wallpaper, desktop_theme]):

themes = []

Expand Down

0 comments on commit 3800ad7

Please sign in to comment.