Rearrange files
This commit is contained in:
96
bin/kutu.rb
Executable file
96
bin/kutu.rb
Executable file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Require X-kutu library for all x11 functions
|
||||
|
||||
require_relative "../src/ruby/X-kutu"
|
||||
|
||||
|
||||
# Require dependencies
|
||||
|
||||
require 'json'
|
||||
require 'socket'
|
||||
|
||||
|
||||
# Initialize X
|
||||
|
||||
if X.deploy >= 0
|
||||
puts "Started kutu WM for X11 successfully! :)"
|
||||
else
|
||||
raise "Failed to deploy X, try running using xinit or startx."
|
||||
end
|
||||
|
||||
|
||||
# Require submodules
|
||||
|
||||
require_relative "../src/ruby/utils"
|
||||
require_relative "../src/ruby/controller"
|
||||
require_relative "../src/ruby/window"
|
||||
require_relative "../src/ruby/workspace"
|
||||
require_relative "../src/ruby/events"
|
||||
require_relative "../src/ruby/commands"
|
||||
|
||||
|
||||
# Cleanup on exit
|
||||
|
||||
at_exit do
|
||||
X.cleanup
|
||||
puts "Exited kutu WM, sadly :("
|
||||
end
|
||||
|
||||
|
||||
# Globals
|
||||
|
||||
$monitors = {}
|
||||
$windows = {}
|
||||
|
||||
$all_windows = []
|
||||
|
||||
$keybind_actions = {}
|
||||
$mousebind_actions = {}
|
||||
|
||||
$mouse_data = {}
|
||||
|
||||
$root = X.get_root
|
||||
$rect = {}
|
||||
|
||||
|
||||
# Initialize monitors
|
||||
|
||||
load_monitors!
|
||||
|
||||
|
||||
# Run startup script
|
||||
|
||||
run File.join(__dir__, "../src/shell/startup.sh")
|
||||
|
||||
|
||||
# Add keybinds
|
||||
|
||||
load File.join(__dir__, "../src/ruby/bindings.rb")
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
loop do
|
||||
sleep 0.001
|
||||
|
||||
if IO.select([$socket], nil, nil, 0)
|
||||
command, sender = $socket.recvfrom 1024
|
||||
reply = handle_command command
|
||||
$socket.send JSON.generate(reply), 0, sender
|
||||
end
|
||||
|
||||
event_pointer = X.next_event
|
||||
handle_event X.translate_event(event_pointer) if !event_pointer.null?
|
||||
|
||||
X.flush
|
||||
end
|
||||
Reference in New Issue
Block a user