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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ release is checked here and released on by hand.
password field brings the on-screen keyboard back after it was put away,
tapping beside the window cancels, and the keyboard goes with the window.

- With a keyboard, Command (Super) with X, C, V and A cuts, copies, pastes
and selects all, in the terminal too, as in upstream Omarchy.

- After typing a Wi-Fi password in the control center and pressing Enter,
the on-screen keyboard stays above the control center until it is put
away, instead of being covered by it where it couldn't be dismissed.
Expand Down
5 changes: 5 additions & 0 deletions desktop/shell/default/i18n/en/shell.json
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@
"shortcuts.none": "No shortcuts",
"shortcuts.group.shell": "Shell",
"shortcuts.group.apps": "Apps",
"shortcuts.group.edit": "Editing",
"shortcuts.group.windows": "Windows",
"shortcuts.group.screenshots": "Screenshots",
"shortcuts.group.hardware": "Hardware Keys",
Expand All @@ -771,6 +772,10 @@
"shortcuts.bar": "Show or Hide the Bar",
"shortcuts.terminal": "Terminal",
"shortcuts.browser": "Browser",
"shortcuts.cut": "Cut",
"shortcuts.copy": "Copy",
"shortcuts.paste": "Paste",
"shortcuts.selectAll": "Select All",
"shortcuts.activity": "Activity",
"shortcuts.screenshot": "Screenshot",
"shortcuts.volumeUp": "Volume Up",
Expand Down
33 changes: 33 additions & 0 deletions desktop/shell/labwc-rc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,39 @@
<keybind key="W-S-space">
<action name="Execute" command="omarchy-toggle-bar" />
</keybind>
<!-- Super (Command on an Apple keyboard) with X, C, V and A: upstream
Omarchy's universal clipboard. Apps get Ctrl; a terminal copies with
Ctrl+Insert and pastes with Ctrl+Shift+V. Ghostty does not take
Ctrl+Shift+C from the virtual keyboard as copy: it reaches the shell
as Ctrl+C and stops what runs. The keys go through the virtual
keyboard (omarchy-wtype), whose modifiers labwc keeps apart from the
held Super. -->
<keybind key="W-x">
<action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl x -m ctrl" />
</keybind>
<keybind key="W-c">
<action name="If">
<query identifier="foot" />
<query identifier="footclient" />
<query identifier="org.omarchy.terminal" />
<query identifier="com.mitchellh.ghostty" />
<then><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl -k Insert -m ctrl" /></then>
<else><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl c -m ctrl" /></else>
</action>
</keybind>
<keybind key="W-v">
<action name="If">
<query identifier="foot" />
<query identifier="footclient" />
<query identifier="org.omarchy.terminal" />
<query identifier="com.mitchellh.ghostty" />
<then><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl -M shift v -m shift -m ctrl" /></then>
<else><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl v -m ctrl" /></else>
</action>
</keybind>
<keybind key="W-a">
<action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl a -m ctrl" />
</keybind>
</keyboard>
<!-- The bottom-edge swipe: over the notification center or the control
center their own drag, which follows the finger (labwc/0009 takes a
Expand Down
48 changes: 48 additions & 0 deletions desktop/shell/migrations/1796378339.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
echo "Command (Super) with X, C, V and A cuts, copies, pastes and selects all"

# Upstream Omarchy's universal clipboard, in labwc-rc.xml now. An existing
# ~/.config/labwc/rc.xml gets the four bindings before </keyboard>, unless it
# binds one of those keys itself; labwc reads it at its next start, the next
# login.
rc="$HOME/.config/labwc/rc.xml"
[[ -f $rc ]] || exit 0
grep -qE '<keybind key="W-[xcva]"' "$rc" && exit 0
grep -q '^ </keyboard>$' "$rc" || exit 0
block=$(cat <<'XML'
<!-- Super (Command on an Apple keyboard) with X, C, V and A: upstream
Omarchy's universal clipboard. Apps get Ctrl; a terminal copies with
Ctrl+Insert and pastes with Ctrl+Shift+V. Ghostty does not take
Ctrl+Shift+C from the virtual keyboard as copy: it reaches the shell
as Ctrl+C and stops what runs. The keys go through the virtual
keyboard (omarchy-wtype), whose modifiers labwc keeps apart from the
held Super. -->
<keybind key="W-x">
<action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl x -m ctrl" />
</keybind>
<keybind key="W-c">
<action name="If">
<query identifier="foot" />
<query identifier="footclient" />
<query identifier="org.omarchy.terminal" />
<query identifier="com.mitchellh.ghostty" />
<then><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl -k Insert -m ctrl" /></then>
<else><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl c -m ctrl" /></else>
</action>
</keybind>
<keybind key="W-v">
<action name="If">
<query identifier="foot" />
<query identifier="footclient" />
<query identifier="org.omarchy.terminal" />
<query identifier="com.mitchellh.ghostty" />
<then><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl -M shift v -m shift -m ctrl" /></then>
<else><action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl v -m ctrl" /></else>
</action>
</keybind>
<keybind key="W-a">
<action name="Execute" command="/usr/libexec/omarchy-wtype -M ctrl a -m ctrl" />
</keybind>
XML
)
awk -v block="$block" '$0 == " </keyboard>" && !done { print block; done = 1 } { print }' "$rc" > "$rc.new"
mv -- "$rc.new" "$rc"
12 changes: 10 additions & 2 deletions desktop/shell/shell/settings/ShortcutsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function unescape(text) {

// What a binding does: { group, label } (i18n keys), or null for one that is
// there only to swallow a key (Execute /usr/bin/true).
// groups: shell, apps, windows, screenshots, hardware, other
// groups: shell, apps, edit, windows, screenshots, hardware, other
var COMMANDS = [
[/omarchy\.dock apps$/, "shell", "shortcuts.launcher"],
[/omarchy\.controlcenter toggle/, "shell", "shortcuts.controlCenter"],
Expand All @@ -48,6 +48,12 @@ var COMMANDS = [
[/omarchy\.menu .*"system"/, "shell", "shortcuts.systemMenu"],
[/omarchy\.menu .*"root"/, "shell", "shortcuts.menu"],
[/omarchy-toggle-bar\b/, "shell", "shortcuts.bar"],
// The universal clipboard: keys sent through the virtual keyboard. Copy and
// paste are an If (terminal or not), named by its first branch.
[/omarchy-wtype .* x -m /, "edit", "shortcuts.cut"],
[/omarchy-wtype .*( c|-k Insert) -m /, "edit", "shortcuts.copy"],
[/omarchy-wtype .* v -m /, "edit", "shortcuts.paste"],
[/omarchy-wtype .* a -m /, "edit", "shortcuts.selectAll"],
[/\bfoot\b|omarchy-launch-terminal/, "apps", "shortcuts.terminal"],
[/\bfirefox\b|omarchy-launch-browser/, "apps", "shortcuts.browser"],
[/omactivity|\bbtop\b/, "apps", "shortcuts.activity"],
Expand Down Expand Up @@ -77,6 +83,8 @@ var ACTIONS = {
function describe(binding) {
var first = binding.actions[0]
if (!first) return null
// <action name="If">…<then><action …/></then>: what it does is its then.
if (first.name === "If" && binding.actions[1]) first = binding.actions[1]
if (first.name === "Execute") {
var command = first.command
if (/^\s*(\/usr\/bin\/)?true\s*$/.test(command)) return null
Expand All @@ -96,7 +104,7 @@ function describe(binding) {
return { group: "other", label: "", command: first.name, rank: 1000 }
}

var GROUPS = ["shell", "apps", "windows", "screenshots", "hardware", "other"]
var GROUPS = ["shell", "apps", "edit", "windows", "screenshots", "hardware", "other"]

// The bindings in their groups: [{ group, rows: [{ keys, label, command, direction }] }].
// Two keys for one thing (Super_L, Super_R) are one row.
Expand Down
87 changes: 87 additions & 0 deletions tests/test_universal_clipboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""Command (Super) with X, C, V and A: upstream Omarchy's universal clipboard under labwc."""
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
import xml.etree.ElementTree as ET

PROJECT = Path(__file__).resolve().parents[1]
RC = PROJECT / 'desktop/shell/labwc-rc.xml'
MIGRATION = PROJECT / 'desktop/shell/migrations/1796378339.sh'
WTYPE = '/usr/libexec/omarchy-wtype'
TERMINALS = ['foot', 'footclient', 'org.omarchy.terminal', 'com.mitchellh.ghostty']


def binding(tree, key):
found = tree.findall("./keyboard/keybind[@key='%s']" % key)
assert len(found) == 1, key
return found[0].find('action')


class Bindings(unittest.TestCase):
def setUp(self):
self.tree = ET.parse(RC)

def test_cut_and_select_all_send_ctrl_everywhere(self):
self.assertEqual(binding(self.tree, 'W-x').get('command'), WTYPE + ' -M ctrl x -m ctrl')
self.assertEqual(binding(self.tree, 'W-a').get('command'), WTYPE + ' -M ctrl a -m ctrl')

def test_copy_and_paste_know_the_terminals(self):
for key, terminal, app in (('W-c', '-M ctrl -k Insert -m ctrl', '-M ctrl c -m ctrl'),
('W-v', '-M ctrl -M shift v -m shift -m ctrl', '-M ctrl v -m ctrl')):
action = binding(self.tree, key)
self.assertEqual(action.get('name'), 'If')
self.assertEqual([q.get('identifier') for q in action.findall('query')], TERMINALS)
self.assertEqual(action.find('then/action').get('command'), WTYPE + ' ' + terminal)
self.assertEqual(action.find('else/action').get('command'), WTYPE + ' ' + app)

def test_a_terminal_never_gets_ctrl_c(self):
# Ctrl+Shift+C from the virtual keyboard reaches Ghostty's shell as
# Ctrl+C, which stops what runs: copy there is Ctrl+Insert.
then = binding(self.tree, 'W-c').find('then/action').get('command')
self.assertNotIn(' c ', then)

def test_foot_copies_and_pastes_with_those_keys(self):
ini = (PROJECT / 'desktop/shell/foot/foot.ini').read_text()
self.assertIn('clipboard-copy=Control+Insert', ini)
self.assertRegex(ini, r'clipboard-paste=.*Control\+Shift\+v')


@unittest.skipUnless(shutil.which('bash'), 'bash is required')
class Migration(unittest.TestCase):
def migrate(self, text):
with tempfile.TemporaryDirectory() as home:
rc = Path(home) / '.config/labwc/rc.xml'
if text is not None:
rc.parent.mkdir(parents=True)
rc.write_text(text)
result = subprocess.run(['bash', '-euo', 'pipefail', str(MIGRATION)], capture_output=True, text=True,
env={'PATH': os.environ['PATH'], 'HOME': home}, timeout=30)
self.assertEqual(result.returncode, 0, result.stderr)
return rc.read_text() if rc.exists() else None

def shipped_without(self):
shipped = RC.read_text()
start = shipped.index(' <!-- Super (Command on an Apple keyboard)')
end = shipped.index(' </keyboard>')
return shipped, shipped[:start] + shipped[end:]

def test_an_older_rc_gets_the_shipped_bindings(self):
shipped, old = self.shipped_without()
self.assertNotIn('omarchy-wtype -M ctrl', old)
migrated = self.migrate(old)
self.assertEqual(migrated, shipped)
ET.fromstring(migrated)
self.assertEqual(self.migrate(migrated), migrated)

def test_a_users_own_binding_is_left_alone(self):
_, old = self.shipped_without()
own = old.replace(' </keyboard>', ' <keybind key="W-v">\n <action name="Close" />\n </keybind>\n </keyboard>')
self.assertEqual(self.migrate(own), own)
self.assertIsNone(self.migrate(None))


if __name__ == '__main__':
unittest.main()