Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src-tauri/Cargo.lock

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

13 changes: 13 additions & 0 deletions src/constants/SystemEventMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ export class SystemEvent {
description: "Randomly capitalizes some letters in the currently highlighted text."
}
}
static get Spongebob(): SystemEventInfo {
return {
type: 'Clipboard',
subtype: 'Spongebob',
displayString: 'SpOnGeBoB tExT',
defaultData: {
type: 'Clipboard',
action: { type: 'Spongebob' }
},
description: "Alternating capitalization of letters in the currently highlighted text."
}
}
static get IncreaseVolume(): SystemEventInfo {
return {
type: 'Volume',
Expand Down Expand Up @@ -95,6 +107,7 @@ export class SystemEvent {
SystemEvent.OpenWebsite,
SystemEvent.Clipboard,
SystemEvent.Sarcasm,
SystemEvent.Spongebob,
SystemEvent.IncreaseVolume,
SystemEvent.DecreaseVolume,
SystemEvent.ToggleMuteVolume,
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export type ClipboardAction =
| { type: 'Paste' }
| { type: 'PasteUserDefinedString'; data: string }
| { type: 'Sarcasm' }
| { type: 'Spongebob' }

export type VolumeAction =
| { type: 'LowerVolume' }
Expand Down
9 changes: 5 additions & 4 deletions wooting-macro-backend/Cargo.lock

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

1 change: 1 addition & 0 deletions wooting-macro-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ log = "0.4"
env_logger = "0.11"
rayon = "1.8"
url = "2.5"
time = "0.3.36"

[profile.release]
lto = true
38 changes: 38 additions & 0 deletions wooting-macro-backend/src/plugin/system_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ impl SystemAction {
// Paste the text again
util::direct_send_hotkey(&send_channel, PASTE_HOTKEY.to_vec()).await?;
}

ClipboardAction::Spongebob => {
let mut ctx = ClipboardContext::new()
.map_err(|err| anyhow::Error::msg(err.to_string()))?;

// Copy the text
util::direct_send_hotkey(&send_channel, COPY_HOTKEY.to_vec()).await?;

// Delay is required to make Discord, and some other apps cooperate properly.
tokio::time::sleep(time::Duration::from_millis(10)).await;

// Transform the text
let content = spongebob_text_transform(
ctx.get_contents()
.map_err(|err| anyhow::Error::msg(err.to_string()))?,
);

ctx.set_contents(content)
.map_err(|err| anyhow::Error::msg(err.to_string()))?;

// Paste the text again
util::direct_send_hotkey(&send_channel, PASTE_HOTKEY.to_vec()).await?;
}
},
}
Ok(())
Expand All @@ -129,6 +152,20 @@ fn transform_text(text: String) -> String {
.collect()
}

// Spongebob text transformation
fn spongebob_text_transform(text: String) -> String {
text.chars()
.enumerate()
.map(|(i, c)| {
if i % 2 == 0 {
c.to_ascii_uppercase()
} else {
c.to_ascii_lowercase()
}
})
.collect()
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Hash, Eq)]
#[serde(tag = "type")]
/// The type of action to perform. This is used to determine which action to perform.
Expand All @@ -139,6 +176,7 @@ pub enum ClipboardAction {
Paste,
PasteUserDefinedString { data: String },
Sarcasm,
Spongebob,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Hash, Eq)]
Expand Down