-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd "$(dirname "$0")" | ||
|
||
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/tmp/tuxclocker-dbus-socket ../inst/bin/tuxclocker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,7 @@ endif | |
if get_option('gui') | ||
subdir('tuxclocker-qt') | ||
endif | ||
|
||
if get_option('cli') | ||
subdir('tuxclocker-cli') | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
import Data.Either | ||
import Data.Functor | ||
import Data.Maybe | ||
import Data.Text (Text) | ||
import DBus | ||
import DBus.Client | ||
import qualified DBus.Introspection as I | ||
|
||
tuxClockerCall :: MethodCall -> MethodCall | ||
tuxClockerCall call = call { methodCallDestination = Just "org.tuxclocker" } | ||
|
||
getObject :: Client -> ObjectPath -> IO I.Object | ||
getObject client path = do | ||
reply <- call_ client $ | ||
tuxClockerCall $ methodCall path "org.freedesktop.DBus.Introspectable" "Introspect" | ||
let xml = fromVariant (head $ methodReturnBody reply) | ||
pure $ fromMaybe | ||
(error ("Invalid introspection XML: " ++ show xml)) | ||
(xml >>= I.parseXML path) | ||
|
||
getName :: Client -> ObjectPath -> IO Variant | ||
getName client path = | ||
let | ||
call = tuxClockerCall $ methodCall path "org.tuxclocker.Node" "name" | ||
in | ||
getProperty client call <&> fromRight (toVariant ("Unnamed" :: Text)) | ||
|
||
printDBusTree :: Client -> IO () | ||
printDBusTree client = | ||
go client "/" where | ||
go client path = do | ||
object <- getObject client path | ||
print $ I.objectPath object | ||
name <- getName client $ I.objectPath object | ||
print name | ||
mapM_ (go client) (I.objectPath <$> I.objectChildren object) | ||
|
||
main = do | ||
client <- connectSystem | ||
printDBusTree client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
install_dir = join_paths(get_option('prefix'), get_option('bindir')) | ||
|
||
run_command('cabal', 'install', '--installdir=@0@'.format(install_dir)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: tuxclocker | ||
version: 0.0.1 | ||
cabal-version: 2.0 | ||
build-type: Simple | ||
|
||
executable tuxclocker | ||
build-depends: base >= 4.16, | ||
dbus >= 1.2, | ||
text >= 2.0 | ||
main-is: Main.hs |