Skip to content

Commit

Permalink
feat: use command as string in config #7
Browse files Browse the repository at this point in the history
  • Loading branch information
jersou committed Jul 2, 2023
1 parent f5bfd49 commit 0eda992
Show file tree
Hide file tree
Showing 23 changed files with 469 additions and 152 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.4.3] - 2023-07-02

### Features

* use command as string in config #7 : the configuration is upgrade at the first
start of version > 0.4.2

BREAKING config file format : config from < v0.4.3 will be automatically upgrade
to v0.4.3 but mouse-actions program < v0.4.3 will not be able to open this
v0.4.3 config format.

## [0.4.2] - 2023-06-18

### Features
Expand Down
28 changes: 27 additions & 1 deletion Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mouse_actions"
version = "0.4.2"
version = "0.4.3"
authors = ["Jerem <jersou@gmail.com>"]
repository = "https://github.com/jersou/mouse-actions"
edition = "2021"
Expand All @@ -18,12 +18,13 @@ log = "0.4.17"
env_logger = "0.10.0"
notify = "5.1.0"
clap = { version = "4.2.1", features = ["derive"] }
regex = "1.7.3"
regex = "1.8.4"
anyhow = "1.0.70"
fs2 = "0.4.3"
tempfile = "3.5.0"
rustix = { version = "0.37.7", features = ["process"] }
users = "0.11.0"
fancy-regex = "0.11.0"

[build-dependencies]
vergen = { version = "8.1.1", features = ["build", "git", "gitcl", "cargo"] }
Expand Down
1 change: 1 addition & 0 deletions Mouse-Actions.iml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/config-editor/src-tauri/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ are optional):
* with some modifiers : shift/Ctrl/Alt...
* with screen edge : Top/Left...
* auto reload config on changes
* fast shape recognition ~200µs (0.0002 secondes) for a config with 30 shapes
* fast shape recognition ~200µs (0.0002 sec) for a config with 30 shapes

## Project status

Expand Down Expand Up @@ -176,7 +176,7 @@ The config file default path is `~/.config/mouse-actions.json`
| `Unknown` | `None`

* `bindings` : array of binding :
* `cmd` : command line to exec, as array of string
* `cmd_str` : command line to exec
* `event`: object :
* `button`: `Left` | `Right` | `Middle` | `Side` | `Extra` | `Forward`
| `Back`
Expand Down Expand Up @@ -388,6 +388,7 @@ cargo audit
### Medium

* CI: build the releases https://github.com/tauri-apps/tauri-action
* add ARM64 target
* create ~/.config if it doesn't exist
* fix exec cmd not found
error `Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })`
Expand Down
Binary file modified config-editor/mace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions config-editor/package-lock.json

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

2 changes: 1 addition & 1 deletion config-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mouse-actions-config-editor",
"private": true,
"version": "0.4.2",
"version": "0.4.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
30 changes: 28 additions & 2 deletions config-editor/src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion config-editor/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mouse_actions_config_editor"
version = "0.4.2"
version = "0.4.3"
description = "Mouse Actions Config Editor"
authors = ["Jerem <jersou@gmail.com>"]
repository = "https://github.com/jersou/mouse-actions"
Expand Down
2 changes: 1 addition & 1 deletion config-editor/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "mouse-actions-gui",
"version": "0.4.2"
"version": "0.4.3"
},
"tauri": {
"allowlist": {
Expand Down
2 changes: 1 addition & 1 deletion config-editor/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function App() {
};
newConfig.bindings?.splice((index ?? -1) + 1, 0, {
uid: self.crypto.randomUUID(),
cmd: ["TODO"],
cmd_str: "TODO",
comment: "TODO",
event: {
button: "Right",
Expand Down
4 changes: 2 additions & 2 deletions config-editor/src/Binding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ export function Binding({
style={{ flex: 1, marginTop: 10, marginBottom: 10 }}
label="Command"
variant="outlined"
value={JSON.stringify(binding.cmd)}
value={binding.cmd_str}
onChange={(e) => {
setBinding?.(
structuredClone({
...binding,
cmd: JSON.parse(e.target.value),
cmd_str: e.target.value,
})
);
}}
Expand Down
2 changes: 1 addition & 1 deletion config-editor/src/Bindings.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default meta;
type Story = StoryObj<typeof meta>;

const binding1: BindingType = {
cmd: ["cmd", "cmd", "cmd"],
cmd_str: "cmd cmd cmd",
comment: "comment",
event: {
event_type: "Click",
Expand Down
2 changes: 1 addition & 1 deletion config-editor/src/config.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type EventType = {
export type BindingType = {
uid?: string;
comment: string;
cmd: string[];
cmd_str: string;
event: EventType;
};

Expand Down
6 changes: 6 additions & 0 deletions src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ pub struct Binding {
#[serde(default)]
pub comment: String,
pub event: ClickEvent,

#[serde(skip_serializing)]
#[serde(default)]
pub cmd: Vec<String>,

#[serde(default)]
pub cmd_str: String,
}
108 changes: 0 additions & 108 deletions src/cmd_from_string.rs

This file was deleted.

Loading

0 comments on commit 0eda992

Please sign in to comment.