Class: Awesomer
- Inherits:
-
Object
- Object
- Awesomer
- Defined in:
- lib/awesomer.rb
Overview
Awesomer is a ruby library for interacting with the awesome
window manager. It replaces the awesome-client
distributed with the window manager.
It’s used by either creating a new Awesomer object, connecting, performing actions, and lastly close the connection:
a = Awesomer.new
a.connect
a.tag_view 2
sleep 1
a.tag_view 3
a.close
A better way to handle this is to contact the window manager using a block. Connecting and closing are then handled automatically:
Awesomer.contact do |a|
a.tag_view 4
a.spawn :urxvt
sleep 3
a.tag_view 5
a.spawn :urxvt
end
Constant Summary collapse
- VERSION =
'1.0.2'
Instance Attribute Summary collapse
-
#screen ⇒ Object
Returns the value of attribute screen.
-
#socket ⇒ Object
Returns the value of attribute socket.
Class Method Summary collapse
-
.contact(screen = 0) {|awesome| ... } ⇒ Object
Contact the awesome window manager using a block.
Instance Method Summary collapse
-
#close ⇒ Object
Close connection to the awesome window manager socket.
-
#connect ⇒ Object
Connect to the awesome window manager socket.
-
#initialize(screen = 0) ⇒ Awesomer
constructor
A new instance of Awesomer.
-
#method_missing(method, *args) ⇒ Object
We take all method calls as possible UICB functions.
Constructor Details
#initialize(screen = 0) ⇒ Awesomer
Returns a new instance of Awesomer.
34 35 36 |
# File 'lib/awesomer.rb', line 34 def initialize(screen = 0) @screen = screen end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
We take all method calls as possible UICB functions.
47 48 49 |
# File 'lib/awesomer.rb', line 47 def method_missing(method, *args) send(method, args.join(' ')) end |
Instance Attribute Details
#screen ⇒ Object
Returns the value of attribute screen.
31 32 33 |
# File 'lib/awesomer.rb', line 31 def screen @screen end |
#socket ⇒ Object
Returns the value of attribute socket.
32 33 34 |
# File 'lib/awesomer.rb', line 32 def socket @socket end |
Class Method Details
Instance Method Details
#close ⇒ Object
Close connection to the awesome window manager socket.
64 65 66 |
# File 'lib/awesomer.rb', line 64 def close @socket.close end |
#connect ⇒ Object
Connect to the awesome window manager socket.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/awesomer.rb', line 52 def connect @socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0) path = File.join(ENV['HOME'], ".awesome_ctl.#@screen") if File.exists? path @socket.connect(Socket.pack_sockaddr_un(path)) else sleep 1 connect end end |