Skip to content

Commit

Permalink
[chore] Update Man Pages and README.md (#273)
Browse files Browse the repository at this point in the history
* [chore] Update Man Pages

* Updated the swhkd.5.scd page for provide information about the
environment sourcing

* Added link to the official sxhkd man pages for config file syntax

* Updated summary about swhks functionality in swhks.1.scd man page

* [chore] Update README.md

* Added link to the SXHKD syntax from the official man pages

* Added information about environment variable sourcing

* [fix] Indentation in swhkd.5.scd
  • Loading branch information
newtoallofthis123 authored Jan 4, 2025
1 parent 5f391b5 commit 75bcd8d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ After opening `swhkd`, you can control the program through signals:

`swhkd` closely follows `sxhkd` syntax, so most existing `sxhkd` configs should
be functional with `swhkd`.
More information about the sxhkd syntax can be found in the official man pages from the [arch wiki](https://man.archlinux.org/man/sxhkd.1).

The default configuration file is in `~/.config/swhkd/swhkdrc` with a fallback to `etc/swhkd/swhkdrc`.

Expand All @@ -58,6 +59,16 @@ vim-plug with `Plug 'waycrate/swhkd-vim'`.

All supported key and modifier names are listed in `man 5 swhkd-keys`.

## Environment Variables

The environment variables are now sourced using the SWHKS binary, running in the background which are then supplemented
to the command that is to be run, thus emulating the environment variables in the default shell.

The commands are executed via *SHELL -c 'command'*, hence the environment is sourced from the default shell.
If the user wants to use a different set of environment variables, they can set the environment variables
in the default shell or export the environment variables within a logged in instance of their shell before
running the SWHKS binary.

## Autostart

### To autostart `swhkd` you can do one of two things
Expand All @@ -79,7 +90,7 @@ environment variables and sending them to the daemon. The daemon
uses these environment variables while running the shell commands.
The daemon only runs shell commands that have been parsed from the config file and there is no way to
run arbitrary shell commands. The server is responsible for only sending the environment variables to the daemon and nothing else.
This seperation of responsibilities ensures security.
This separation of responsibilities ensures security.

So yes, you're safe!

Expand Down
21 changes: 18 additions & 3 deletions docs/swhkd.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@ swhkd - Hotkey daemon inspired by sxhkd written in Rust

# CONFIG FILE

- A global config can be defined in *~/.config/swhkd/swhkdrc*, with a
fallback to */etc/swhkd/swhkdrc*. Swhkd attempts to look in your *$XDG_CONFIG_HOME*, failing which it defaults to *~/.config*.
- A local config overrides the global one. Local configs should be placed in the root of the project.
- A global config can be defined in *~/.config/swhkd/swhkdrc*, with a
fallback to */etc/swhkd/swhkdrc*. Swhkd attempts to look in your *$XDG_CONFIG_HOME*, failing which it defaults to *~/.config*.
- A local config overrides the global one. Local configs should be placed in the root of the project.
- The config file can also be specified with the *-c* flag.

# ENVIRONMENT

- The environment variables are now sourced using the SWHKS binary, running in the background.
- The environment variables are then supplemented to the command that is to be run, thus emulating the
environment variables in the default shell.
- The commands are executed via *SHELL -c 'command'*, hence the environment is sourced from the default shell.
- If the user wants to use a different set of environment variables, they can set the environment variables
in the default shell or export the environment variables within a logged in instance of their shell before
running the SWHKS binary.

# SYNTAX

The syntax of the configuration file is identical to sxhkd and builds upon it.
More information about the syntax can be found from the official sxhkd documentation:
https://man.archlinux.org/man/sxhkd.1, however a brief summary of it is provided below.

Each line of the configuration file is interpreted as so:
- If it is empty or starts with #, it is ignored.
- If it starts with a space, it is read as a command.
Expand Down
2 changes: 1 addition & 1 deletion docs/swhks.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ swhks(1) "github.com/shinyzenith/swhkd" "General Commands Manual"

# NAME

swhks - Server for swhkd, used to run user level commands over IPC.
swhks - Server for swhkd, used to source environment variables from the default shell to supply to swhkd.

# SYNOPSIS

Expand Down

0 comments on commit 75bcd8d

Please sign in to comment.