Update bindings api
This commit is contained in:
+30
-33
@@ -1,26 +1,26 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Require X-kutu library for all x11 functions
|
||||
# require x-kutu library for all x11 functions
|
||||
|
||||
require_relative "../src/ruby/X-kutu"
|
||||
require_relative "../src/ruby/x-kutu"
|
||||
|
||||
|
||||
# Require dependencies
|
||||
# require dependencies
|
||||
|
||||
require 'json'
|
||||
require 'socket'
|
||||
|
||||
|
||||
# Initialize X
|
||||
# initialize x
|
||||
|
||||
if X.deploy >= 0
|
||||
puts "Started kutu WM for X11 successfully! :)"
|
||||
if x.deploy >= 0
|
||||
puts "started kutu wm for x11 successfully! :)"
|
||||
else
|
||||
raise "Failed to deploy X, try running using xinit or startx."
|
||||
raise "failed to deploy x, try running using xinit or startx."
|
||||
end
|
||||
|
||||
|
||||
# Require submodules
|
||||
# require submodules
|
||||
|
||||
require_relative "../src/ruby/utils"
|
||||
require_relative "../src/ruby/controller"
|
||||
@@ -28,17 +28,19 @@ require_relative "../src/ruby/window"
|
||||
require_relative "../src/ruby/workspace"
|
||||
require_relative "../src/ruby/events"
|
||||
require_relative "../src/ruby/commands"
|
||||
require_relative "../src/ruby/factory"
|
||||
require_relative "../src/ruby/config"
|
||||
|
||||
|
||||
# Cleanup on exit
|
||||
# cleanup on exit
|
||||
|
||||
at_exit do
|
||||
X.cleanup
|
||||
puts "Exited kutu WM, sadly :("
|
||||
x.cleanup
|
||||
puts "exited kutu wm, sadly :("
|
||||
end
|
||||
|
||||
|
||||
# Globals
|
||||
# globals
|
||||
|
||||
$monitors = {}
|
||||
$windows = {}
|
||||
@@ -50,47 +52,42 @@ $mousebind_actions = {}
|
||||
|
||||
$mouse_data = {}
|
||||
|
||||
$root = X.get_root
|
||||
$root = x.get_root
|
||||
$rect = {}
|
||||
|
||||
|
||||
# Initialize monitors
|
||||
# initialize monitors
|
||||
|
||||
load_monitors!
|
||||
|
||||
|
||||
# Run startup script
|
||||
# load config
|
||||
|
||||
run File.join(__dir__, "../src/shell/startup.sh")
|
||||
load_config!
|
||||
|
||||
|
||||
# Add keybinds
|
||||
# setup unix socket
|
||||
|
||||
load File.join(__dir__, "../src/ruby/bindings.rb")
|
||||
sock_path = "/tmp/kutu.sock"
|
||||
file.delete sock_path if file.exist? sock_path
|
||||
|
||||
$socket = socket.new :unix, :dgram
|
||||
$socket.bind socket.pack_sockaddr_un(sock_path)
|
||||
|
||||
|
||||
# Setup unix socket
|
||||
|
||||
SOCK_PATH = "/tmp/kutu.sock"
|
||||
File.delete SOCK_PATH if File.exist? SOCK_PATH
|
||||
|
||||
$socket = Socket.new :UNIX, :DGRAM
|
||||
$socket.bind Socket.pack_sockaddr_un(SOCK_PATH)
|
||||
|
||||
|
||||
# Main loop
|
||||
# main loop
|
||||
|
||||
loop do
|
||||
sleep 0.001
|
||||
|
||||
if IO.select([$socket], nil, nil, 0)
|
||||
if io.select([$socket], nil, nil, 0)
|
||||
command, sender = $socket.recvfrom 1024
|
||||
reply = handle_command command
|
||||
$socket.send JSON.generate(reply), 0, sender
|
||||
$socket.send json.generate(reply), 0, sender
|
||||
end
|
||||
|
||||
event_pointer = X.next_event
|
||||
handle_event X.translate_event(event_pointer) if !event_pointer.null?
|
||||
event_pointer = x.next_event
|
||||
handle_event x.translate_event(event_pointer) if !event_pointer.null?
|
||||
|
||||
X.flush
|
||||
x.flush
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user