fidget 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/fidget/platform/linux.rb +31 -3
- data/lib/fidget/platform/windows.rb +2 -2
- data/lib/fidget/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 053aecb8ac134a93352ee94ad74e2b5d53391157
|
4
|
+
data.tar.gz: a03308997ca134b329f148f477865d630b336efb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e891bb9f07dab6e7c6406cb1693cc59c84cf3ad3fce0f02741010af879d88e63cb9c982190ac418e53afa5fc63e981de9ed59d5d33ee97ed999ec053aaf76349
|
7
|
+
data.tar.gz: 75076bdb11679fe0e55c2df30e62a03ef218d64e841923e2569113e5b7c7c795728f86eee6bdb96e6661f24eff86ea61674226a7aac82779a007ee8bb0af6d1d
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class Fidget::Platform
|
2
|
+
require "dbus"
|
3
|
+
|
2
4
|
def self.current_process(options)
|
3
5
|
options = munge(options)
|
4
6
|
suspend(options)
|
@@ -35,7 +37,7 @@ class Fidget::Platform
|
|
35
37
|
end
|
36
38
|
options
|
37
39
|
end
|
38
|
-
|
40
|
+
private_class_method :munge
|
39
41
|
|
40
42
|
def self.root_win
|
41
43
|
ids = `xwininfo -root`.each_line.collect do |line|
|
@@ -45,12 +47,25 @@ class Fidget::Platform
|
|
45
47
|
raise "Parsing xwininfo failed" unless ids.size == 1
|
46
48
|
ids.first
|
47
49
|
end
|
48
|
-
|
50
|
+
private_class_method :root_win
|
49
51
|
|
50
52
|
def self.suspend(options)
|
51
53
|
if options.include? :display
|
54
|
+
# I'm sure that if we tried, we could find yet another way to do this
|
52
55
|
system("xdg-screensaver suspend #{root_win}")
|
56
|
+
system('xset s off')
|
57
|
+
system('xset s noblank')
|
53
58
|
system('xset -dpms')
|
59
|
+
|
60
|
+
# xdg-screensaver doesn't actually seem to work, but making DBus calls ourself does.
|
61
|
+
# This is possibly because the inhibit expires when the dbus-session command terminates
|
62
|
+
# I don't know if this will work in other distros though. Yay for consistency. *\o/*
|
63
|
+
begin
|
64
|
+
dbus_screensaver.Inhibit(root_win, 'Administratively disabled')
|
65
|
+
rescue => e
|
66
|
+
STDERR.puts 'Fidget: DBus action failed.'
|
67
|
+
STDERR.puts e.backtrace.join "\n"
|
68
|
+
end
|
54
69
|
end
|
55
70
|
|
56
71
|
if options.include? :blanking
|
@@ -63,7 +78,11 @@ class Fidget::Platform
|
|
63
78
|
def self.resume(options)
|
64
79
|
if options.include? :display
|
65
80
|
system("xdg-screensaver resume #{root_win}")
|
66
|
-
system('xset dpms')
|
81
|
+
system('xset +dpms')
|
82
|
+
system('xset s on')
|
83
|
+
|
84
|
+
# if we have a cookie, we can trust that DBus works
|
85
|
+
dbus_screensaver.Uninhibit(@@cookie) if @@cookie
|
67
86
|
end
|
68
87
|
|
69
88
|
if options.include? :blanking
|
@@ -72,4 +91,13 @@ class Fidget::Platform
|
|
72
91
|
end
|
73
92
|
private_class_method :resume
|
74
93
|
|
94
|
+
def self.dbus_screensaver
|
95
|
+
session = DBus.session_bus
|
96
|
+
service = session['org.freedesktop.ScreenSaver']
|
97
|
+
object = service['/ScreenSaver']
|
98
|
+
object.introspect
|
99
|
+
object['org.freedesktop.ScreenSaver']
|
100
|
+
end
|
101
|
+
private_class_method :dbus_screensaver
|
102
|
+
|
75
103
|
end
|
@@ -40,7 +40,7 @@ class Fidget::Platform
|
|
40
40
|
options.flatten!
|
41
41
|
options.compact!
|
42
42
|
options = [:display, :sleep] if options.empty?
|
43
|
-
options = [:display, :sleep, :away] if options == [:all]
|
43
|
+
options = [:display, :sleep, :simulate, :away] if options == [:all]
|
44
44
|
|
45
45
|
terms = {
|
46
46
|
:display => ES_DISPLAY_REQUIRED,
|
@@ -57,7 +57,7 @@ class Fidget::Platform
|
|
57
57
|
state = Win32API.new('kernel32','SetThreadExecutionState','L')
|
58
58
|
state.call(ES_CONTINUOUS|mode)
|
59
59
|
|
60
|
-
if options.include? :
|
60
|
+
if options.include? :simulate
|
61
61
|
@@kb_poker = Thread.new do
|
62
62
|
kb = Win32API.new('user32.dll', 'keybd_event', 'nnnn', 'v')
|
63
63
|
loop do
|
data/lib/fidget/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fidget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Ford
|
@@ -9,7 +9,21 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-01-08 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-dbus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: |2
|
14
28
|
Fidget was inspired by the OS X commandline `caffeinate` tool, which in turn
|
15
29
|
was inspired by the Caffeine menubar tool. However, this tool is cross platform
|