Skip to content
Merged
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
56 changes: 56 additions & 0 deletions ipc-scripts/workspace-names-expo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/python3

#
# The MIT License (MIT)
#
# Copyright (c) 2025 Scott Moreau <oreaus@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

from wayfire import WayfireSocket
import json

# Simple script to show workspace names when expo is active

sock = WayfireSocket()

sock.watch(["plugin-activation-state-changed"])

def show_option_values(enabled):
json_string = "{\"workspace-names/show_option_values\": \"true\"}"
sock.set_option_values(json.loads(json_string))
if enabled:
json_string = "{\"workspace-names/show_option_names\": \"true\"}"
else:
json_string = "{\"workspace-names/show_option_names\": \"false\"}"
sock.set_option_values(json.loads(json_string))

while True:
try:
msg = sock.read_next_event()
if "event" in msg:
plugin_changed_info = msg
if plugin_changed_info["plugin"] == "expo":
if plugin_changed_info["state"] == True:
show_option_values(True)
elif plugin_changed_info["state"] == False:
show_option_values(False)
except KeyboardInterrupt:
exit(0)
110 changes: 110 additions & 0 deletions ipc-scripts/workspace-names-setter-gtk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/python3

#
# The MIT License (MIT)
#
# Copyright (c) 2025 Scott Moreau <oreaus@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

from wayfire import WayfireSocket
import signal
import json
import sys
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk, GLib

# Simple script to set workspace names with a gui

sock = WayfireSocket()

class MyWindow(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_default_size(400, 300)
self.set_title("Workspace Names Setter")
self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.entry = Gtk.Entry()
self.entry.set_placeholder_text("Workspace " + self.get_workspace_number())
self.entry.connect("activate", self.on_entry_activate)
self.button = Gtk.Button()
self.button.set_label("Set Workspace Name")
self.button.connect("clicked", self.on_button_clicked)
self.box.append(self.entry)
self.box.append(self.button)
self.set_child(self.box)

self.connect("close-request", self.on_window_close)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.on_sigint)

def on_window_close(self, window):
self.get_application().quit()

def on_sigint(self):
self.get_application().quit()

def get_workspace_number(self):
output = sock.get_focused_output()
return str(int(output["workspace"]["x"]) + int(output["workspace"]["y"]) * int(output["workspace"]["grid_width"]) + 1)

def set_workspace_name(self, name):
output = sock.get_focused_output()
output_name = output["name"]
current_workspace = self.get_workspace_number()
json_string = "{\"workspace-names/" + output_name + "_workspace_" + current_workspace + "\": \"" + name + "\"}"
try:
sock.set_option_values(json.loads(json_string))
exit(0)
except Exception as e:
print(e)
print("The option \"" + output_name + "_workspace_" + current_workspace + " = Name\" must exist in the [workspace-names] section of the wayfire config file before using this application.")
dialog = Gtk.MessageDialog(
transient_for=self,
modal=True,
message_type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.OK,
text=f"{e}\n\nThe option \"" + output_name + "_workspace_" + current_workspace + " = Name\" must exist in the [workspace-names] section of the wayfire config file before using this application.",
)
dialog.connect("response", self.on_dialog_response)
dialog.present()

def on_dialog_response(self, dialog, response_id):
dialog.destroy()
exit(0)

def on_entry_activate(self, entry):
name = self.entry.get_text()
if name:
self.set_workspace_name(name)

def on_button_clicked(self, button):
name = self.entry.get_text()
if name:
self.set_workspace_name(name)

def on_activate(app):
win = MyWindow(application=app)
win.present()

if __name__ == "__main__":
app = Gtk.Application(application_id="wayfire.workspace-names.setter")
app.connect("activate", on_activate)
app.run(None)
25 changes: 24 additions & 1 deletion ipc-scripts/workspace-names-setter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
#!/usr/bin/python3

#
# The MIT License (MIT)
#
# Copyright (c) 2025 Scott Moreau <oreaus@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

from wayfire import WayfireSocket
import json
import sys
Expand All @@ -8,7 +32,6 @@

if len(sys.argv) != 2:
print("Invalid usage, exactly one argument required: a workspace name for the current output and workspace.")
print(len(sys.argv))
exit(-1)

sock = WayfireSocket()
Expand Down