initial commit
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
builddir
|
11
LICENSE
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Copyright 2020 Chris Cromer
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
50
README.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# TUF Manager
|
||||||
|
|
||||||
|
## License
|
||||||
|
[3-Clause BSD License](LICENSE)
|
||||||
|
|
||||||
|
## Build requirements
|
||||||
|
To build TUF Manager the following is needed:
|
||||||
|
|
||||||
|
- vala
|
||||||
|
- valadoc
|
||||||
|
- glib
|
||||||
|
- gtk3
|
||||||
|
- dbus
|
||||||
|
- polkit
|
||||||
|
- polkit-gobject
|
||||||
|
- gmodule-export
|
||||||
|
|
||||||
|
## Build options
|
||||||
|
|
||||||
|
- valadocs
|
||||||
|
|
||||||
|
Build TUF Manager's vala documentation.
|
||||||
|
- valadocs-deps
|
||||||
|
|
||||||
|
Build external valadocs that TUF Manager utilizes and calls.
|
||||||
|
- always-authenticated
|
||||||
|
|
||||||
|
Authentication is not required to use the TUF Server that runs in the background as a daemon, if this is set to false polkit is used for authentication. Setting this to false is more secure, but also makes things like auto restore of settings on login impossible to do without a password.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
There are 2 programs and 1 daemon supplied by TUF Manager.
|
||||||
|
|
||||||
|
- tuf-cli
|
||||||
|
|
||||||
|
This allows controlling the TUF laptop functions via command line interface.
|
||||||
|
- tuf-gui
|
||||||
|
|
||||||
|
This supplies a graphical interface to control the TUF laptop.
|
||||||
|
- tuf-server
|
||||||
|
|
||||||
|
This is the daemon that runs in the background and handles all requests from both tuf-cli and tuf-gui.
|
||||||
|
|
||||||
|
## Future plans
|
||||||
|
|
||||||
|
- Manpage
|
||||||
|
- Config options for both tuf-gui and tuf-cli
|
||||||
|
- Status bar icon that allows control of the notebook
|
||||||
|
- Notifications of fan mode change via status bar
|
||||||
|
- Restore last known settings on login via status bar icon
|
||||||
|
- Service scripts for various init systems instead of relying on dbus activation
|
17
data/dbus/meson.build
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
dbus_config_data = configuration_data()
|
||||||
|
dbus_config_data.set('LIBEXEC_DIR', join_paths(get_option('prefix'), get_option('libexecdir'), meson.project_name()))
|
||||||
|
|
||||||
|
dbus_config_data_file = configure_file(
|
||||||
|
input: 'org.tuf.manager.server.service.in',
|
||||||
|
output: 'org.tuf.manager.server.service',
|
||||||
|
configuration: dbus_config_data
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
['org.tuf.manager.server.conf'],
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'dbus-1', 'system.d')
|
||||||
|
)
|
||||||
|
install_data(
|
||||||
|
dbus_config_data_file,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'dbus-1', 'system-services')
|
||||||
|
)
|
23
data/dbus/org.tuf.manager.server.conf
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||||
|
<busconfig>
|
||||||
|
<!-- Only root can own the service -->
|
||||||
|
<policy user="root">
|
||||||
|
<allow own="org.tuf.manager.server"/>
|
||||||
|
</policy>
|
||||||
|
|
||||||
|
<!-- Allow anyone to invoke methods on the interfaces -->
|
||||||
|
<policy context="default">
|
||||||
|
<allow send_destination="org.tuf.manager.server"
|
||||||
|
send_interface="org.tuf.manager.server"/>
|
||||||
|
|
||||||
|
<allow send_destination="org.tuf.manager.server"
|
||||||
|
send_interface="org.freedesktop.DBus.Introspectable"/>
|
||||||
|
<allow send_destination="org.tuf.manager.server"
|
||||||
|
send_interface="org.freedesktop.DBus.Peer"/>
|
||||||
|
<allow send_destination="org.tuf.manager.server"
|
||||||
|
send_interface="org.freedesktop.DBus.Properties"/>
|
||||||
|
</policy>
|
||||||
|
</busconfig>
|
||||||
|
|
4
data/dbus/org.tuf.manager.server.service.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[D-BUS Service]
|
||||||
|
Name=org.tuf.manager.server
|
||||||
|
Exec=@LIBEXEC_DIR@/tuf-server
|
||||||
|
User=root
|
12
data/gschema/meson.build
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# server doesn't need gschema, only gui or cli
|
||||||
|
if build_gui or build_cli
|
||||||
|
gnome = import('gnome')
|
||||||
|
gschemas = files(
|
||||||
|
'org.tuf.manager.gschema.xml'
|
||||||
|
)
|
||||||
|
gnome.compile_schemas(
|
||||||
|
build_by_default: true,
|
||||||
|
depend_files: gschemas
|
||||||
|
)
|
||||||
|
install_data('org.tuf.manager.gschema.xml', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas'))
|
||||||
|
endif
|
49
data/gschema/org.tuf.manager.gschema.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<schemalist>
|
||||||
|
<schema id="org.tuf.manager" path="/org/tuf/manager/" gettext-domain="tuf-manager">
|
||||||
|
<key name="restore" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Should TUF Manager restore previous settings when run</summary>
|
||||||
|
<description>
|
||||||
|
Should TUF Manager restore previous settings when run
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="fan-mode" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Fan mode</summary>
|
||||||
|
<description>
|
||||||
|
The saved fan mode
|
||||||
|
0 is balanced
|
||||||
|
1 is turbo
|
||||||
|
2 is silent
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="keyboard-mode" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Keyboard mode</summary>
|
||||||
|
<description>
|
||||||
|
The saved keyboard mode
|
||||||
|
0 is static
|
||||||
|
1 is breathing
|
||||||
|
2 is color cycle
|
||||||
|
3 is strobing
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="keyboard-speed" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Keyboard speed</summary>
|
||||||
|
<description>
|
||||||
|
The saved keyboard speed
|
||||||
|
0 is slow
|
||||||
|
1 is medium
|
||||||
|
2 is fast
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
<key name="keyboard-color" type="s">
|
||||||
|
<default>"rgb(255,0,0)"</default>
|
||||||
|
<summary>Keyboard color</summary>
|
||||||
|
<description>
|
||||||
|
The saved keyboard color in rgb format
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
BIN
data/icons/128x128/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
data/icons/16x16/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
data/icons/192x192/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
data/icons/22x22/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
data/icons/24x24/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
data/icons/256x256/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
data/icons/32x32/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
data/icons/36x36/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
data/icons/42x42/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
data/icons/480x480/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 135 KiB |
BIN
data/icons/48x48/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
data/icons/512x512/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 148 KiB |
BIN
data/icons/64x64/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
data/icons/72x72/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
data/icons/8x8/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
data/icons/96x96/apps/tuf-manager.png
Normal file
After Width: | Height: | Size: 18 KiB |
19
data/icons/meson.build
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
if build_gui
|
||||||
|
install_data('8x8/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/8x8/apps'))
|
||||||
|
install_data('16x16/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/16x16/apps'))
|
||||||
|
install_data('22x22/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/22x22/apps'))
|
||||||
|
install_data('24x24/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/24x24/apps'))
|
||||||
|
install_data('32x32/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/32x32/apps'))
|
||||||
|
install_data('36x36/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/36x36/apps'))
|
||||||
|
install_data('42x42/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/42x42/apps'))
|
||||||
|
install_data('48x48/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/48x48/apps'))
|
||||||
|
install_data('64x64/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/64x64/apps'))
|
||||||
|
install_data('72x72/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/72x72/apps'))
|
||||||
|
install_data('96x96/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/96x96/apps'))
|
||||||
|
install_data('128x128/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/128x128/apps'))
|
||||||
|
install_data('192x192/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/192x192/apps'))
|
||||||
|
install_data('256x256/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/256x256/apps'))
|
||||||
|
install_data('480x480/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/480x480/apps'))
|
||||||
|
install_data('512x512/apps/tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/512x512/apps'))
|
||||||
|
install_data('tuf-manager.png', install_dir: join_paths(get_option('datadir'), 'icons'))
|
||||||
|
endif
|
BIN
data/icons/tuf-manager.png
Normal file
After Width: | Height: | Size: 285 KiB |
16
data/meson.build
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
if build_gui
|
||||||
|
i18n.merge_file(
|
||||||
|
input: 'tuf-manager.desktop.in',
|
||||||
|
output: 'tuf-manager.desktop',
|
||||||
|
po_dir: join_paths(meson.source_root(), 'po'),
|
||||||
|
type: 'desktop',
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'applications')
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
subdir('dbus')
|
||||||
|
subdir('polkit')
|
||||||
|
subdir('ui')
|
||||||
|
subdir('icons')
|
||||||
|
subdir('gschema')
|
10
data/polkit/meson.build
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
if not always_authenticated
|
||||||
|
i18n.merge_file(
|
||||||
|
input: 'org.tuf.manager.policy.in',
|
||||||
|
output: 'org.tuf.manager.policy',
|
||||||
|
po_dir: join_paths(meson.source_root(), 'po'),
|
||||||
|
type: 'xml',
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'polkit-1', 'actions')
|
||||||
|
)
|
||||||
|
endif
|
17
data/polkit/org.tuf.manager.policy.in
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE policyconfig PUBLIC
|
||||||
|
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
|
||||||
|
<policyconfig>
|
||||||
|
<vendor>TUF Manager</vendor>
|
||||||
|
<vendor_url>https://git.cromer.cl/cromer/tuf-manager/</vendor_url>
|
||||||
|
<icon_name>package-x-generic</icon_name>
|
||||||
|
<action id="org.tuf.manager.save">
|
||||||
|
<message>Authentication is required</message>
|
||||||
|
<defaults>
|
||||||
|
<allow_any>no</allow_any>
|
||||||
|
<allow_inactive>auth_admin_keep</allow_inactive>
|
||||||
|
<allow_active>auth_admin_keep</allow_active>
|
||||||
|
</defaults>
|
||||||
|
</action>
|
||||||
|
</policyconfig>
|
9
data/tuf-manager.desktop.in
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=TUF Manager
|
||||||
|
GenericName=TUF Manager
|
||||||
|
Comment=Softare to manage the fan mode and rgb keyboard.
|
||||||
|
Icon=tuf-manager
|
||||||
|
StartupNotify=true
|
||||||
|
Exec=tuf-gui
|
||||||
|
Categories=System;
|
11
data/ui/meson.build
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
if build_gui
|
||||||
|
gnome = import('gnome')
|
||||||
|
tuf_manager_gresource = gnome.compile_resources(
|
||||||
|
'tuf_manager_gresource',
|
||||||
|
'tuf.manager.gresource.xml',
|
||||||
|
source_dir: '.',
|
||||||
|
c_name: 'resource_tuf_manager',
|
||||||
|
export: true,
|
||||||
|
install_header: true
|
||||||
|
)
|
||||||
|
endif
|
BIN
data/ui/pixdata/tuf-manager.png
Normal file
After Width: | Height: | Size: 12 KiB |
7
data/ui/tuf.manager.gresource.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/cl/cromer/tuf-manager">
|
||||||
|
<file preprocess="xml-stripblanks">tuf.manager.window.ui</file>
|
||||||
|
<file preprocess="to-pixdata">pixdata/tuf-manager.png</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
266
data/ui/tuf.manager.window.ui
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.22.2
|
||||||
|
|
||||||
|
Copyright (c) 2020
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the <organization> nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
Author: Chris Cromer
|
||||||
|
|
||||||
|
-->
|
||||||
|
<interface domain="tuf-manager">
|
||||||
|
<requires lib="gtk+" version="3.10"/>
|
||||||
|
<!-- interface-license-type bsd3c -->
|
||||||
|
<!-- interface-name TUF Manager -->
|
||||||
|
<!-- interface-description Software to control fans and keyboard on ASUS TUF notebooks -->
|
||||||
|
<!-- interface-copyright 2020 -->
|
||||||
|
<!-- interface-authors Chris Cromer -->
|
||||||
|
<template class="TUFManagerGUIMainWindow" parent="GtkApplicationWindow">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="title" translatable="yes">TUF Manager</property>
|
||||||
|
<property name="resizable">False</property>
|
||||||
|
<property name="default_width">320</property>
|
||||||
|
<property name="default_height">240</property>
|
||||||
|
<property name="icon_name">tuf-manager</property>
|
||||||
|
<property name="show_menubar">False</property>
|
||||||
|
<child type="titlebar">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkNotebook">
|
||||||
|
<property name="name">Tabs</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="label" translatable="yes">Mode</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="keyboard_mode">
|
||||||
|
<property name="name">Keyboard Mode</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="active">0</property>
|
||||||
|
<items>
|
||||||
|
<item translatable="yes">Static</item>
|
||||||
|
<item translatable="yes">Breathing</item>
|
||||||
|
<item translatable="yes">Color Cycle</item>
|
||||||
|
<item translatable="yes">Strobing</item>
|
||||||
|
</items>
|
||||||
|
<signal name="changed" handler="on_keyboard_mode_changed" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="label" translatable="yes">Speed</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="keyboard_speed">
|
||||||
|
<property name="name">Speed</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="active">0</property>
|
||||||
|
<items>
|
||||||
|
<item translatable="yes">Slow</item>
|
||||||
|
<item translatable="yes">Medium</item>
|
||||||
|
<item translatable="yes">Fast</item>
|
||||||
|
</items>
|
||||||
|
<signal name="changed" handler="on_speed_changed" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColorChooserWidget" id="keyboard_color">
|
||||||
|
<property name="name">Color</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="rgba">rgb(0,0,0)</property>
|
||||||
|
<property name="use_alpha">False</property>
|
||||||
|
<property name="show_editor">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="set_color">
|
||||||
|
<property name="label" translatable="yes">Set color</property>
|
||||||
|
<property name="name">Set color</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<signal name="clicked" handler="on_set_color_clicked" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="tab">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Keyboard lighting</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="tab_fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">start</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="hexpand">True</property>
|
||||||
|
<property name="vexpand">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="label" translatable="yes">Mode</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="fan_mode">
|
||||||
|
<property name="name">Fan Mode</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_left">5</property>
|
||||||
|
<property name="margin_right">5</property>
|
||||||
|
<property name="margin_top">5</property>
|
||||||
|
<property name="margin_bottom">5</property>
|
||||||
|
<property name="active">0</property>
|
||||||
|
<items>
|
||||||
|
<item translatable="yes">Balanced</item>
|
||||||
|
<item translatable="yes">Turbo</item>
|
||||||
|
<item translatable="yes">Silent</item>
|
||||||
|
</items>
|
||||||
|
<signal name="changed" handler="on_fan_mode_changed" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child type="tab">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Fan control</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">1</property>
|
||||||
|
<property name="tab_fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child type="tab">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</template>
|
||||||
|
</interface>
|
45
docs/meson.build
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
docs_enabled = get_option('valadocs')
|
||||||
|
if docs_enabled
|
||||||
|
valadoc = find_program('valadoc', required: docs_enabled)
|
||||||
|
vala_doc_sources = server_vala_sources
|
||||||
|
if build_cli
|
||||||
|
vala_doc_sources += cli_vala_sources
|
||||||
|
endif
|
||||||
|
if build_gui
|
||||||
|
vala_doc_sources += gui_vala_sources
|
||||||
|
endif
|
||||||
|
vala_doc_sources += error_vala_sources
|
||||||
|
vala_doc_sources += config_data_file
|
||||||
|
valadocs_deps = get_option('valadocs-deps')
|
||||||
|
docs_deps = [
|
||||||
|
'--pkg=polkit-gobject-1',
|
||||||
|
'--pkg=posix',
|
||||||
|
'--pkg=gtk+-3.0'
|
||||||
|
]
|
||||||
|
if valadocs_deps
|
||||||
|
docs_deps += ['--deps']
|
||||||
|
endif
|
||||||
|
custom_target(
|
||||||
|
'valadoc',
|
||||||
|
input: vala_doc_sources,
|
||||||
|
output: 'valadoc',
|
||||||
|
command: [ valadoc,
|
||||||
|
docs_deps,
|
||||||
|
'--doclet=html',
|
||||||
|
'--internal',
|
||||||
|
'--private',
|
||||||
|
'--force',
|
||||||
|
'--package-name=@0@'.format(meson.project_name()),
|
||||||
|
'--package-version=@0@'.format(meson.project_version()),
|
||||||
|
'--vapidir=@0@'.format(join_paths(meson.source_root(), 'vapi')),
|
||||||
|
'--directory=@OUTDIR@/valadoc',
|
||||||
|
vala_doc_sources
|
||||||
|
],
|
||||||
|
build_by_default: true,
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
install_data('../LICENSE', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
|
||||||
|
install_data('../README.md', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
|
29
meson.build
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
project(
|
||||||
|
'tuf-manager',
|
||||||
|
[
|
||||||
|
'c',
|
||||||
|
'vala'
|
||||||
|
],
|
||||||
|
version: '0.1.0',
|
||||||
|
license: 'BSD-3',
|
||||||
|
default_options:
|
||||||
|
[
|
||||||
|
'b_ndebug=if-release',
|
||||||
|
'c_std=c18',
|
||||||
|
'warning_level=3'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
add_global_arguments(
|
||||||
|
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
|
||||||
|
language: 'c'
|
||||||
|
)
|
||||||
|
|
||||||
|
always_authenticated = get_option('always-authenticated')
|
||||||
|
build_cli = get_option('build-cli')
|
||||||
|
build_gui = get_option('build-gui')
|
||||||
|
|
||||||
|
subdir('po')
|
||||||
|
subdir('data')
|
||||||
|
subdir('src')
|
||||||
|
subdir('docs')
|
||||||
|
subdir('script')
|
30
meson_options.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
option(
|
||||||
|
'valadocs',
|
||||||
|
type: 'boolean',
|
||||||
|
value: true,
|
||||||
|
description: 'Build valadocs'
|
||||||
|
)
|
||||||
|
option(
|
||||||
|
'valadocs-deps',
|
||||||
|
type: 'boolean',
|
||||||
|
value: false,
|
||||||
|
description: 'Build the valadocs of the dependencies'
|
||||||
|
)
|
||||||
|
option(
|
||||||
|
'build-cli',
|
||||||
|
type : 'boolean',
|
||||||
|
value: true,
|
||||||
|
description: 'Build the command line interface to TUF Manager'
|
||||||
|
)
|
||||||
|
option(
|
||||||
|
'build-gui',
|
||||||
|
type : 'boolean',
|
||||||
|
value: true,
|
||||||
|
description: 'Build the graphical user interface to TUF Manager'
|
||||||
|
)
|
||||||
|
option(
|
||||||
|
'always-authenticated',
|
||||||
|
type : 'boolean',
|
||||||
|
value: true,
|
||||||
|
description: 'User is always authenticated, so no password is necessary'
|
||||||
|
)
|
1
po/LINGUAS
Normal file
@ -0,0 +1 @@
|
|||||||
|
es
|
14
po/POTFILES
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
src/cli.vala
|
||||||
|
src/config.vala.in
|
||||||
|
src/error.vala
|
||||||
|
src/common.vala
|
||||||
|
src/gui.vala
|
||||||
|
src/gui-window.vala
|
||||||
|
src/main.vala.in
|
||||||
|
src/server.vala
|
||||||
|
src/server-interface.vala
|
||||||
|
src/server-main.vala
|
||||||
|
data/tuf-manager.desktop.in
|
||||||
|
data/polkit/org.tuf.manager.policy.in
|
||||||
|
data/gschema/org.tuf.manager.gschema.xml
|
||||||
|
data/ui/tuf.manager.window.ui
|
263
po/es.po
Normal file
@ -0,0 +1,263 @@
|
|||||||
|
# Spanish translations for tuf-manager package.
|
||||||
|
# Copyright (C) 2020 THE tuf-manager'S COPYRIGHT HOLDER
|
||||||
|
# This file is distributed under the same license as the tuf-manager package.
|
||||||
|
# Automatically generated, 2020.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: tuf-manager\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2020-08-03 22:20-0400\n"
|
||||||
|
"PO-Revision-Date: 2020-08-03 22:22-0400\n"
|
||||||
|
"Last-Translator: Chris Cromer <chris@cromer.cl>\n"
|
||||||
|
"Language-Team: none\n"
|
||||||
|
"Language: es\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Generator: Poedit 2.3\n"
|
||||||
|
"X-Poedit-SourceCharset: UTF-8\n"
|
||||||
|
|
||||||
|
#: src/cli.vala:145
|
||||||
|
msgid "Invalid arguments!\n"
|
||||||
|
msgstr "¡Valor invalido!\n"
|
||||||
|
|
||||||
|
#: src/cli.vala:151
|
||||||
|
msgid "Version: "
|
||||||
|
msgstr "Versión: "
|
||||||
|
|
||||||
|
#: src/cli.vala:161 src/gui-window.vala:86
|
||||||
|
msgid "Client version: "
|
||||||
|
msgstr "Versión del cliente: "
|
||||||
|
|
||||||
|
#: src/cli.vala:162 src/gui-window.vala:87
|
||||||
|
msgid "Server version: "
|
||||||
|
msgstr "Versión del servidor: "
|
||||||
|
|
||||||
|
#: src/cli.vala:166
|
||||||
|
msgid "Current fan mode: Balanced\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:169
|
||||||
|
msgid "Current fan mode: Turbo\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:172
|
||||||
|
msgid "Current fan mode: Silent\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:175 src/cli.vala:193
|
||||||
|
msgid "Error: Could not get current fan mode!\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:181
|
||||||
|
msgid "Current keyboard lighting: Static\n"
|
||||||
|
msgstr "Iluminación de teclado\n"
|
||||||
|
|
||||||
|
#: src/cli.vala:184
|
||||||
|
msgid "Current keyboard lighting: Breathing\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:187
|
||||||
|
msgid "Current keyboard lighting: Color Cycle\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:190
|
||||||
|
msgid "Current keyboard lighting: Strobing\n"
|
||||||
|
msgstr "Iluminación de teclado\n"
|
||||||
|
|
||||||
|
#: src/gui-window.vala:71
|
||||||
|
msgid "The current running tuf-server version doesn't match the gui version!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:96
|
||||||
|
msgid "Current fan mode: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:99
|
||||||
|
msgid "Error: Could not get current fan mode!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:106
|
||||||
|
msgid "Current keyboard mode: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:109
|
||||||
|
msgid "Error: Could not get current keyboard mode!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:116
|
||||||
|
msgid "Current keyboard speed: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:119
|
||||||
|
msgid "Error: Could not get current keyboard speed!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:125
|
||||||
|
msgid "Current keyboard color: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/main.vala.in:34
|
||||||
|
msgid "Another instance of TUF Manager is already running!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/server.vala:154 src/server.vala:217 src/server.vala:236
|
||||||
|
#: src/server.vala:249 src/server.vala:262 src/server.vala:321
|
||||||
|
#: src/server.vala:328 src/server.vala:335 src/server.vala:342
|
||||||
|
#: src/server.vala:349 src/server.vala:359 src/server.vala:414
|
||||||
|
#: src/server.vala:426 src/server.vala:433 src/server.vala:444
|
||||||
|
#: src/server.vala:499 src/server.vala:511 src/server.vala:518
|
||||||
|
msgid "Failed to open stream!"
|
||||||
|
msgstr "¡Fallo al abrir stream!"
|
||||||
|
|
||||||
|
#: src/server.vala:159 src/server.vala:241 src/server.vala:254
|
||||||
|
#: src/server.vala:267 src/server.vala:364 src/server.vala:449
|
||||||
|
msgid "File is empty!"
|
||||||
|
msgstr "¡El archivo está vacío!"
|
||||||
|
|
||||||
|
#: src/server.vala:164 src/server.vala:369 src/server.vala:454
|
||||||
|
msgid "File contains invalid value!"
|
||||||
|
msgstr "¡El archivo contiene un valor invalido!"
|
||||||
|
|
||||||
|
#: src/server.vala:222 src/server.vala:419 src/server.vala:504
|
||||||
|
msgid "Invalid value!"
|
||||||
|
msgstr "¡Valor invalido!"
|
||||||
|
|
||||||
|
#: data/tuf-manager.desktop.in:4 data/tuf-manager.desktop.in:5
|
||||||
|
#: data/ui/tuf.manager.window.ui:41
|
||||||
|
msgid "TUF Manager"
|
||||||
|
msgstr "Administrador TUF"
|
||||||
|
|
||||||
|
#: data/tuf-manager.desktop.in:6
|
||||||
|
msgid "Softare to manage the fan mode and rgb keyboard."
|
||||||
|
msgstr "Software para gestionar el modo ventilador y el teclado rgb."
|
||||||
|
|
||||||
|
# Not translatable
|
||||||
|
#: data/tuf-manager.desktop.in:7
|
||||||
|
msgid "tuf-manager"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/polkit/org.tuf.manager.policy.in:10
|
||||||
|
msgid "Authentication is required"
|
||||||
|
msgstr "Se requiere autenticación"
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:5
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:6
|
||||||
|
msgid "Should TUF Manager restore previous settings when run"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:12
|
||||||
|
msgid "Fan mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:13
|
||||||
|
msgid "The saved fan mode 0 is balanced 1 is turbo 2 is silent"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:22
|
||||||
|
msgid "Keyboard mode"
|
||||||
|
msgstr "Modo del teclado"
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:23
|
||||||
|
msgid ""
|
||||||
|
"The saved keyboard mode 0 is static 1 is breathing 2 is color cycle 3 is "
|
||||||
|
"strobing"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:33
|
||||||
|
msgid "Keyboard speed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:34
|
||||||
|
msgid "The saved keyboard speed 0 is slow 1 is medium 2 is fast"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:43
|
||||||
|
msgid "Keyboard color"
|
||||||
|
msgstr "Color del teclado"
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:44
|
||||||
|
msgid "The saved keyboard color in rgb format"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:73 data/ui/tuf.manager.window.ui:212
|
||||||
|
msgid "Mode"
|
||||||
|
msgstr "Modo"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:91
|
||||||
|
msgid "Static"
|
||||||
|
msgstr "Estática"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:92
|
||||||
|
msgid "Breathing"
|
||||||
|
msgstr "Respiración"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:93
|
||||||
|
msgid "Color Cycle"
|
||||||
|
msgstr "Ciclo de Color"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:94
|
||||||
|
msgid "Strobing"
|
||||||
|
msgstr "Estroboscópica"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:112
|
||||||
|
msgid "Speed"
|
||||||
|
msgstr "Velocidad"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:130
|
||||||
|
msgid "Slow"
|
||||||
|
msgstr "Lenta"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:131
|
||||||
|
msgid "Medium"
|
||||||
|
msgstr "Media"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:132
|
||||||
|
msgid "Fast"
|
||||||
|
msgstr "Rapida"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:162
|
||||||
|
msgid "Set color"
|
||||||
|
msgstr "Establecer color"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:187
|
||||||
|
msgid "Keyboard lighting"
|
||||||
|
msgstr "Iluminación de teclado"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:230
|
||||||
|
msgid "Balanced"
|
||||||
|
msgstr "Balanceada"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:231
|
||||||
|
msgid "Turbo"
|
||||||
|
msgstr "Turbo"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:232
|
||||||
|
msgid "Silent"
|
||||||
|
msgstr "Silenciosa"
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:250
|
||||||
|
msgid "Fan control"
|
||||||
|
msgstr "Control de ventilador"
|
||||||
|
|
||||||
|
#~ msgid "Authentication failed!"
|
||||||
|
#~ msgstr "¡Autenticación falló!"
|
||||||
|
|
||||||
|
#~ msgid "Brightness"
|
||||||
|
#~ msgstr "Brillo"
|
||||||
|
|
||||||
|
#~ msgid "Off"
|
||||||
|
#~ msgstr "Apagada"
|
||||||
|
|
||||||
|
#~ msgid "Low"
|
||||||
|
#~ msgstr "Baja"
|
||||||
|
|
||||||
|
#~ msgid "High"
|
||||||
|
#~ msgstr "Alta"
|
||||||
|
|
||||||
|
#~ msgid "The TUF server is busy and can't handle the request at the moment!"
|
||||||
|
#~ msgstr ""
|
||||||
|
#~ "¡El servidor TUF está ocupado y no puede manejar la solicitud en este "
|
||||||
|
#~ "momento!"
|
9
po/meson.build
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
i18n = import('i18n')
|
||||||
|
i18n.gettext(
|
||||||
|
meson.project_name(),
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
'--directory=' + meson.source_root(),
|
||||||
|
'--from-code=UTF-8'
|
||||||
|
]
|
||||||
|
)
|
240
po/tuf-manager.pot
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||||
|
# This file is distributed under the same license as the tuf-manager package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: tuf-manager\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2020-08-03 22:20-0400\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"Language: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
#: src/cli.vala:145
|
||||||
|
msgid "Invalid arguments!\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:151
|
||||||
|
msgid "Version: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:161 src/gui-window.vala:86
|
||||||
|
msgid "Client version: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:162 src/gui-window.vala:87
|
||||||
|
msgid "Server version: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:166
|
||||||
|
msgid "Current fan mode: Balanced\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:169
|
||||||
|
msgid "Current fan mode: Turbo\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:172
|
||||||
|
msgid "Current fan mode: Silent\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:175 src/cli.vala:193
|
||||||
|
msgid "Error: Could not get current fan mode!\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:181
|
||||||
|
msgid "Current keyboard lighting: Static\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:184
|
||||||
|
msgid "Current keyboard lighting: Breathing\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:187
|
||||||
|
msgid "Current keyboard lighting: Color Cycle\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/cli.vala:190
|
||||||
|
msgid "Current keyboard lighting: Strobing\n"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:71
|
||||||
|
msgid "The current running tuf-server version doesn't match the gui version!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:96
|
||||||
|
msgid "Current fan mode: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:99
|
||||||
|
msgid "Error: Could not get current fan mode!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:106
|
||||||
|
msgid "Current keyboard mode: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:109
|
||||||
|
msgid "Error: Could not get current keyboard mode!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:116
|
||||||
|
msgid "Current keyboard speed: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:119
|
||||||
|
msgid "Error: Could not get current keyboard speed!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/gui-window.vala:125
|
||||||
|
msgid "Current keyboard color: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/main.vala.in:34
|
||||||
|
msgid "Another instance of TUF Manager is already running!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/server.vala:154 src/server.vala:217 src/server.vala:236
|
||||||
|
#: src/server.vala:249 src/server.vala:262 src/server.vala:321
|
||||||
|
#: src/server.vala:328 src/server.vala:335 src/server.vala:342
|
||||||
|
#: src/server.vala:349 src/server.vala:359 src/server.vala:414
|
||||||
|
#: src/server.vala:426 src/server.vala:433 src/server.vala:444
|
||||||
|
#: src/server.vala:499 src/server.vala:511 src/server.vala:518
|
||||||
|
msgid "Failed to open stream!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/server.vala:159 src/server.vala:241 src/server.vala:254
|
||||||
|
#: src/server.vala:267 src/server.vala:364 src/server.vala:449
|
||||||
|
msgid "File is empty!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/server.vala:164 src/server.vala:369 src/server.vala:454
|
||||||
|
msgid "File contains invalid value!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/server.vala:222 src/server.vala:419 src/server.vala:504
|
||||||
|
msgid "Invalid value!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/tuf-manager.desktop.in:4 data/tuf-manager.desktop.in:5
|
||||||
|
#: data/ui/tuf.manager.window.ui:41
|
||||||
|
msgid "TUF Manager"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/tuf-manager.desktop.in:6
|
||||||
|
msgid "Softare to manage the fan mode and rgb keyboard."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/tuf-manager.desktop.in:7
|
||||||
|
msgid "tuf-manager"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/polkit/org.tuf.manager.policy.in:10
|
||||||
|
msgid "Authentication is required"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:5
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:6
|
||||||
|
msgid "Should TUF Manager restore previous settings when run"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:12
|
||||||
|
msgid "Fan mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:13
|
||||||
|
msgid "The saved fan mode 0 is balanced 1 is turbo 2 is silent"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:22
|
||||||
|
msgid "Keyboard mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:23
|
||||||
|
msgid ""
|
||||||
|
"The saved keyboard mode 0 is static 1 is breathing 2 is color cycle 3 is "
|
||||||
|
"strobing"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:33
|
||||||
|
msgid "Keyboard speed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:34
|
||||||
|
msgid "The saved keyboard speed 0 is slow 1 is medium 2 is fast"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:43
|
||||||
|
msgid "Keyboard color"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/gschema/org.tuf.manager.gschema.xml:44
|
||||||
|
msgid "The saved keyboard color in rgb format"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:73 data/ui/tuf.manager.window.ui:212
|
||||||
|
msgid "Mode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:91
|
||||||
|
msgid "Static"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:92
|
||||||
|
msgid "Breathing"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:93
|
||||||
|
msgid "Color Cycle"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:94
|
||||||
|
msgid "Strobing"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:112
|
||||||
|
msgid "Speed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:130
|
||||||
|
msgid "Slow"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:131
|
||||||
|
msgid "Medium"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:132
|
||||||
|
msgid "Fast"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:162
|
||||||
|
msgid "Set color"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:187
|
||||||
|
msgid "Keyboard lighting"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:230
|
||||||
|
msgid "Balanced"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:231
|
||||||
|
msgid "Turbo"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:232
|
||||||
|
msgid "Silent"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: data/ui/tuf.manager.window.ui:250
|
||||||
|
msgid "Fan control"
|
||||||
|
msgstr ""
|
4
script/compile_schemas.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh -eu
|
||||||
|
|
||||||
|
echo "Compiling gsettings schemas..."
|
||||||
|
glib-compile-schemas "${MESON_INSTALL_DESTDIR_PREFIX}/share/glib-2.0/schemas"
|
5
script/meson.build
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# only gui or cli need gschema
|
||||||
|
if build_gui or build_cli
|
||||||
|
valadoc = find_program('glib-compile-schemas')
|
||||||
|
meson.add_install_script('compile_schemas.sh')
|
||||||
|
endif
|
299
src/cli.vala
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The CLI namespace handles all command line related usage
|
||||||
|
*/
|
||||||
|
namespace CLI {
|
||||||
|
public class TUFManagerApp : Application {
|
||||||
|
#if ALWAYS_AUTHENTICATED
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* The subprocess that will contain our tty polkit agent
|
||||||
|
*/
|
||||||
|
Subprocess? pkttyagent = null;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private enum FanMode {
|
||||||
|
BALANCED,
|
||||||
|
TURBO,
|
||||||
|
SILENT
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum KeyboardMode {
|
||||||
|
STATIC,
|
||||||
|
BREATHING,
|
||||||
|
COLOR_CYCLE,
|
||||||
|
STROBING
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum KeyboardSpeed {
|
||||||
|
SLOW,
|
||||||
|
MEDIUM,
|
||||||
|
FAST
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool invalid = false;
|
||||||
|
|
||||||
|
private bool help = false;
|
||||||
|
private bool info = false;
|
||||||
|
private bool version = false;
|
||||||
|
|
||||||
|
private bool fan = false;
|
||||||
|
private FanMode? fan_mode = null;
|
||||||
|
|
||||||
|
private bool lighting;
|
||||||
|
private KeyboardMode? keyboard_mode = null;
|
||||||
|
|
||||||
|
public TUFManagerApp () {
|
||||||
|
Object (application_id: "cl.cromer.tuf.manager", flags: ApplicationFlags.HANDLES_COMMAND_LINE);
|
||||||
|
set_inactivity_timeout (1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void activate () {
|
||||||
|
this.hold ();
|
||||||
|
this.release ();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _command_line (ApplicationCommandLine command_line) {
|
||||||
|
try {
|
||||||
|
connect_dbus ();
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
command_line.printerr ("Error: " + e.message + "\n");
|
||||||
|
}
|
||||||
|
string[] args = command_line.get_arguments ();
|
||||||
|
// tuf-cli fan silent
|
||||||
|
// tuf-cli color #FFFFFF
|
||||||
|
// tuf-cli lighting strobe
|
||||||
|
// tuf-cli help
|
||||||
|
// tuf-cli info
|
||||||
|
// tuf-cli version
|
||||||
|
// same as info // tuf-cli
|
||||||
|
if (args.length == 1) {
|
||||||
|
help = true;
|
||||||
|
}
|
||||||
|
else if (args.length > 1) {
|
||||||
|
switch (args[1]) {
|
||||||
|
case "version":
|
||||||
|
version = true;
|
||||||
|
check_second_argument (args);
|
||||||
|
break;
|
||||||
|
case "help":
|
||||||
|
help = true;
|
||||||
|
check_second_argument (args);
|
||||||
|
break;
|
||||||
|
case "info":
|
||||||
|
info = true;
|
||||||
|
check_second_argument (args);
|
||||||
|
break;
|
||||||
|
case "fan":
|
||||||
|
fan = true;
|
||||||
|
break;
|
||||||
|
case "lighting":
|
||||||
|
lighting = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
invalid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 2) {
|
||||||
|
if (fan) {
|
||||||
|
switch (args[2]) {
|
||||||
|
case "balanced":
|
||||||
|
fan_mode = FanMode.BALANCED;
|
||||||
|
break;
|
||||||
|
case "turbo":
|
||||||
|
fan_mode = FanMode.TURBO;
|
||||||
|
break;
|
||||||
|
case "silent":
|
||||||
|
fan_mode = FanMode.SILENT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
invalid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lighting) {
|
||||||
|
switch (args[2]) {
|
||||||
|
case "static":
|
||||||
|
keyboard_mode = KeyboardMode.STATIC;
|
||||||
|
break;
|
||||||
|
case "breath":
|
||||||
|
keyboard_mode = KeyboardMode.BREATHING;
|
||||||
|
break;
|
||||||
|
case "cycle":
|
||||||
|
keyboard_mode = KeyboardMode.COLOR_CYCLE;
|
||||||
|
break;
|
||||||
|
case "strobe":
|
||||||
|
keyboard_mode = KeyboardMode.STROBING;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
invalid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invalid) {
|
||||||
|
command_line.printerr (_ ("Invalid arguments!\n"));
|
||||||
|
print_usage (command_line);
|
||||||
|
release_cli ();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (version) {
|
||||||
|
command_line.print (_ ("Version: ") + VERSION + "\n");
|
||||||
|
release_cli ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (help) {
|
||||||
|
print_usage (command_line);
|
||||||
|
release_cli ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (info) {
|
||||||
|
command_line.print (_ ("Client version: ") + VERSION + "\n");
|
||||||
|
command_line.print (_ ("Server version: ") + get_server_version () + "\n");
|
||||||
|
var mode = get_fan_mode ();
|
||||||
|
switch (mode) {
|
||||||
|
case 0:
|
||||||
|
command_line.print (_ ("Current fan mode: Balanced\n"));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
command_line.print (_ ("Current fan mode: Turbo\n"));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
command_line.print (_ ("Current fan mode: Silent\n"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
command_line.printerr (_ ("Error: Could not get current fan mode!\n"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mode = get_keyboard_mode ();
|
||||||
|
switch (mode) {
|
||||||
|
case 0:
|
||||||
|
command_line.print (_ ("Current keyboard lighting: Static\n"));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
command_line.print (_ ("Current keyboard lighting: Breathing\n"));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
command_line.print (_ ("Current keyboard lighting: Color Cycle\n"));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
command_line.print (_ ("Current keyboard lighting: Strobing\n"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
command_line.printerr (_ ("Error: Could not get current fan mode!\n"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
release_cli ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (fan) {
|
||||||
|
#if ALWAYS_AUTHENTICATED
|
||||||
|
int mode = fan_mode;
|
||||||
|
tuf_server.procedure_finished.connect (release_cli);
|
||||||
|
set_fan_mode (mode);
|
||||||
|
#else
|
||||||
|
try {
|
||||||
|
pkttyagent = new Subprocess.newv ({"pkttyagent"}, SubprocessFlags.NONE);
|
||||||
|
Timeout.add (200, () => {
|
||||||
|
int mode = fan_mode;
|
||||||
|
tuf_server.procedure_finished.connect (release_cli);
|
||||||
|
set_fan_mode (mode);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
command_line.printerr ("Error: " + e.message + "\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (lighting) {
|
||||||
|
#if ALWAYS_AUTHENTICATED
|
||||||
|
int mode = keyboard_mode;
|
||||||
|
tuf_server.procedure_finished.connect (release_cli);
|
||||||
|
set_keyboard_mode (mode);
|
||||||
|
#else
|
||||||
|
try {
|
||||||
|
pkttyagent = new Subprocess.newv ({"pkttyagent"}, SubprocessFlags.NONE);
|
||||||
|
|
||||||
|
Timeout.add (200, () => {
|
||||||
|
int mode = keyboard_mode;
|
||||||
|
tuf_server.procedure_finished.connect (release_cli);
|
||||||
|
set_keyboard_mode (mode);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
command_line.printerr ("Error: " + e.message + "\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check_second_argument (string[] args) {
|
||||||
|
if (args.length > 2) {
|
||||||
|
invalid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print_usage (ApplicationCommandLine command_line) {
|
||||||
|
command_line.print ("Usage: tuf-cli COMMAND [SUBCOMMAND] ...\n\n");
|
||||||
|
command_line.print (" version Print the version of tuf-cli\n");
|
||||||
|
command_line.print (" help Show this help screen\n");
|
||||||
|
command_line.print (" fan [balanced, turbo, silent] Set the fan mode\n");
|
||||||
|
command_line.print (" lighting [static, breath, cycle, stobe] Set the keyboard lighting\n");
|
||||||
|
command_line.print (" speed [slow, medium, fast] Set the keyboard lighting speed\n");
|
||||||
|
command_line.print (" color [#XXXXXX] Set the keyboadd color\n");
|
||||||
|
command_line.print (" info Show the current config\n\n");
|
||||||
|
command_line.print ("Examples:\n");
|
||||||
|
command_line.print (" Silence fan: tuf-cli fan silent\n");
|
||||||
|
command_line.print (" Change RGB color: tuf-cli color #FF0000\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method releases the command line program from it's loop
|
||||||
|
*/
|
||||||
|
public void release_cli () {
|
||||||
|
#if ALWAYS_AUTHENTICATED
|
||||||
|
#else
|
||||||
|
if (pkttyagent != null) {
|
||||||
|
pkttyagent.force_exit ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
this.release ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int command_line (ApplicationCommandLine command_line) {
|
||||||
|
// keep the application running until we are done with this commandline
|
||||||
|
this.hold ();
|
||||||
|
int res = _command_line (command_line);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
148
src/common.vala
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
private TUFServerInterface tuf_server;
|
||||||
|
private BusName bus_name;
|
||||||
|
|
||||||
|
private void connect_dbus () throws TUFError {
|
||||||
|
bus_name = new BusName ("org.tuf.manager");
|
||||||
|
connect_tuf_server ();
|
||||||
|
if (get_server_version () != VERSION) {
|
||||||
|
throw new TUFError.UNMATCHED_VERSIONS ("The server and client versions do not match!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connect_tuf_server () {
|
||||||
|
try {
|
||||||
|
tuf_server = Bus.get_proxy_sync (BusType.SYSTEM, "org.tuf.manager.server", "/org/tuf/manager/server");
|
||||||
|
}
|
||||||
|
catch (IOError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? get_server_version () {
|
||||||
|
try {
|
||||||
|
return tuf_server.get_server_version ();
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int get_fan_mode () {
|
||||||
|
try {
|
||||||
|
return tuf_server.get_fan_mode ();
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_fan_mode (int mode) {
|
||||||
|
try {
|
||||||
|
tuf_server.set_fan_mode (mode, bus_name);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Gdk.RGBA get_keyboard_color () {
|
||||||
|
try {
|
||||||
|
return tuf_server.get_keyboard_color ();
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
return Gdk.RGBA ();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_keyboard_color (Gdk.RGBA color) {
|
||||||
|
try {
|
||||||
|
tuf_server.set_keyboard_color (color, bus_name);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int get_keyboard_mode () {
|
||||||
|
try {
|
||||||
|
return tuf_server.get_keyboard_mode ();
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_keyboard_mode (int mode) {
|
||||||
|
try {
|
||||||
|
tuf_server.set_keyboard_mode (mode, bus_name);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int get_keyboard_speed () {
|
||||||
|
try {
|
||||||
|
return tuf_server.get_keyboard_speed ();
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_keyboard_speed (int speed) {
|
||||||
|
try {
|
||||||
|
tuf_server.set_keyboard_speed (speed, bus_name);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
src/config.vala.in
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The package name used for translations
|
||||||
|
*/
|
||||||
|
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
|
||||||
|
/**
|
||||||
|
* The version of the application
|
||||||
|
*/
|
||||||
|
public const string VERSION = "@VERSION@";
|
||||||
|
/**
|
||||||
|
* The location of the thermal control
|
||||||
|
*/
|
||||||
|
public const string THERMAL_PATH = "/sys/devices/platform/faustus/throttle_thermal_policy";
|
||||||
|
public const string RED_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_red";
|
||||||
|
public const string GREEN_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_green";
|
||||||
|
public const string BLUE_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_blue";
|
||||||
|
public const string KEYBOARD_MODE_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_mode";
|
||||||
|
public const string KEYBOARD_FLAGS_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_flags";
|
||||||
|
public const string KEYBOARD_SPEED_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_speed";
|
||||||
|
public const string KEYBOARD_SET_PATH = "/sys/devices/platform/faustus/kbbl/kbbl_set";
|
||||||
|
}
|
41
src/error.vala
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* This contains errors related to TUF Manager
|
||||||
|
*/
|
||||||
|
public errordomain TUFError {
|
||||||
|
/**
|
||||||
|
* The stream failed to open
|
||||||
|
*/
|
||||||
|
STREAM,
|
||||||
|
/**
|
||||||
|
* An invalid value was returned
|
||||||
|
*/
|
||||||
|
INVALID_VALUE,
|
||||||
|
/**
|
||||||
|
* The server is busy and can't do another task yet
|
||||||
|
*/
|
||||||
|
BUSY,
|
||||||
|
/**
|
||||||
|
* The client and serer version don't match
|
||||||
|
*/
|
||||||
|
UNMATCHED_VERSIONS,
|
||||||
|
UNAUTHORIZED
|
||||||
|
}
|
||||||
|
}
|
247
src/gui-window.vala
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The GUI namespace contains a GTK based interface to interact with the TUF laptop
|
||||||
|
*/
|
||||||
|
namespace GUI {
|
||||||
|
/**
|
||||||
|
* The main window to show to the user
|
||||||
|
*/
|
||||||
|
[GtkTemplate (ui = "/cl/cromer/tuf-manager/tuf.manager.window.ui")]
|
||||||
|
public class MainWindow : Gtk.ApplicationWindow {
|
||||||
|
/**
|
||||||
|
* This is used to make sure that the sysfs files are not written to until everything is initialized
|
||||||
|
*/
|
||||||
|
private bool initialized = false;
|
||||||
|
private Settings settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fan mode combo box
|
||||||
|
*/
|
||||||
|
[GtkChild]
|
||||||
|
private Gtk.ComboBoxText fan_mode;
|
||||||
|
|
||||||
|
[GtkChild]
|
||||||
|
private Gtk.ComboBoxText keyboard_mode;
|
||||||
|
|
||||||
|
[GtkChild]
|
||||||
|
private Gtk.ComboBoxText keyboard_speed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color chooser widget
|
||||||
|
*/
|
||||||
|
[GtkChild]
|
||||||
|
private Gtk.ColorChooserWidget keyboard_color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the main window
|
||||||
|
* @param application The application used to make the GLib object
|
||||||
|
*/
|
||||||
|
public MainWindow (Gtk.Application application) {
|
||||||
|
Object (application: application);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize () {
|
||||||
|
settings = new Settings ("org.tuf.manager");
|
||||||
|
try {
|
||||||
|
connect_dbus ();
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s:\n", e.message);
|
||||||
|
if (e.code == TUFError.UNMATCHED_VERSIONS) {
|
||||||
|
Gtk.MessageDialog msg;
|
||||||
|
msg = new Gtk.MessageDialog (this,
|
||||||
|
Gtk.DialogFlags.MODAL,
|
||||||
|
Gtk.MessageType.ERROR,
|
||||||
|
Gtk.ButtonsType.CLOSE,
|
||||||
|
_ ("The current running tuf-server version doesn't match the gui version!"));
|
||||||
|
msg.response.connect ((response_id) => {
|
||||||
|
msg.destroy ();
|
||||||
|
this.close ();
|
||||||
|
});
|
||||||
|
msg.show ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
print (_ ("Client version: ") + VERSION + "\n");
|
||||||
|
print (_ ("Server version: ") + get_server_version () + "\n");
|
||||||
|
|
||||||
|
if (settings.get_boolean ("restore")) {
|
||||||
|
restore ();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Get the fan speed
|
||||||
|
// 0 - normal
|
||||||
|
// 1 - boost
|
||||||
|
// 2 - silent
|
||||||
|
var mode = get_fan_mode ();
|
||||||
|
if (mode >= 0) {
|
||||||
|
fan_mode.set_active (mode);
|
||||||
|
print (_ ("Current fan mode: ") + fan_mode.get_active_text () + "\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stderr.printf ("%s\n", _ ("Error: Could not get current fan mode!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the keyboard mode
|
||||||
|
mode = get_keyboard_mode ();
|
||||||
|
if (mode >= 0) {
|
||||||
|
keyboard_mode.set_active (mode);
|
||||||
|
if (mode == 2) {
|
||||||
|
keyboard_color.sensitive = false;
|
||||||
|
}
|
||||||
|
if (mode == 0 || mode == 3) {
|
||||||
|
keyboard_speed.sensitive = false;
|
||||||
|
}
|
||||||
|
print (_ ("Current keyboard mode: ") + keyboard_mode.get_active_text () + "\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stderr.printf ("%s\n", _ ("Error: Could not get current keyboard mode!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the keyboard speed
|
||||||
|
var speed = get_keyboard_speed ();
|
||||||
|
if (speed >= 0) {
|
||||||
|
keyboard_speed.set_active (mode);
|
||||||
|
print (_ ("Current keyboard speed: ") + keyboard_speed.get_active_text () + "\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stderr.printf ("%s\n", _ ("Error: Could not get current keyboard speed!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the keyboard color
|
||||||
|
var color = get_keyboard_color ();
|
||||||
|
keyboard_color.set_rgba (color);
|
||||||
|
print (_ ("Current keyboard color: ") + color.to_string () + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restore () {
|
||||||
|
var mode = settings.get_int ("fan-mode");
|
||||||
|
if (mode >= 0 && mode <= 2) {
|
||||||
|
if (get_fan_mode () != mode) {
|
||||||
|
set_fan_mode (mode);
|
||||||
|
}
|
||||||
|
fan_mode.set_active (mode);
|
||||||
|
}
|
||||||
|
print (_ ("Current fan mode: ") + fan_mode.get_active_text () + "\n");
|
||||||
|
|
||||||
|
mode = settings.get_int ("keyboard-mode");
|
||||||
|
if (mode >= 0 && mode <= 3) {
|
||||||
|
if (get_keyboard_mode () != mode) {
|
||||||
|
set_keyboard_mode (mode);
|
||||||
|
}
|
||||||
|
keyboard_mode.set_active (mode);
|
||||||
|
if (mode == 2) {
|
||||||
|
keyboard_color.sensitive = false;
|
||||||
|
}
|
||||||
|
if (mode == 0 || mode == 3) {
|
||||||
|
keyboard_speed.sensitive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print (_ ("Current keyboard mode: ") + keyboard_mode.get_active_text () + "\n");
|
||||||
|
|
||||||
|
var speed = settings.get_int ("keyboard-speed");
|
||||||
|
if (speed >= 0 && speed <= 2) {
|
||||||
|
if (get_keyboard_speed () != speed) {
|
||||||
|
set_keyboard_speed (speed);
|
||||||
|
}
|
||||||
|
keyboard_speed.set_active (speed);
|
||||||
|
}
|
||||||
|
print (_ ("Current keyboard speed: ") + keyboard_speed.get_active_text () + "\n");
|
||||||
|
|
||||||
|
var color = settings.get_string ("keyboard-color");
|
||||||
|
var rgba = Gdk.RGBA ();
|
||||||
|
rgba.parse (color);
|
||||||
|
if (!get_keyboard_color ().equal (rgba)) {
|
||||||
|
set_keyboard_color (rgba);
|
||||||
|
}
|
||||||
|
keyboard_color.set_rgba (rgba);
|
||||||
|
print (_ ("Current keyboard color: ") + color.to_string () + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user changes the fan mode
|
||||||
|
*
|
||||||
|
* * 1 - normal mode
|
||||||
|
* * 2 - boost mode
|
||||||
|
* * 3 - silent mode
|
||||||
|
* @param combo_box The combo box that changed
|
||||||
|
*/
|
||||||
|
[GtkCallback]
|
||||||
|
public void on_fan_mode_changed (Gtk.ComboBox combo_box) {
|
||||||
|
if (initialized) {
|
||||||
|
int mode = combo_box.get_active ();
|
||||||
|
set_fan_mode (mode);
|
||||||
|
|
||||||
|
settings.set_int ("fan-mode", mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user changes the keyboard lighting mode
|
||||||
|
* @param combo_box The combo box that changed
|
||||||
|
*/
|
||||||
|
[GtkCallback]
|
||||||
|
public void on_keyboard_mode_changed (Gtk.ComboBox combo_box) {
|
||||||
|
if (initialized) {
|
||||||
|
int mode = combo_box.get_active ();
|
||||||
|
if (mode == 2) {
|
||||||
|
keyboard_color.sensitive = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keyboard_color.sensitive = true;
|
||||||
|
}
|
||||||
|
if (mode == 1 || mode == 2) {
|
||||||
|
keyboard_speed.sensitive = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keyboard_speed.sensitive = false;
|
||||||
|
}
|
||||||
|
set_keyboard_mode (mode);
|
||||||
|
|
||||||
|
settings.set_int ("keyboard-mode", mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[GtkCallback]
|
||||||
|
public void on_speed_changed (Gtk.ComboBox combo_box) {
|
||||||
|
if (initialized) {
|
||||||
|
int speed = combo_box.get_active ();
|
||||||
|
set_keyboard_speed (speed);
|
||||||
|
|
||||||
|
settings.set_int ("keyboard-speed", speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[GtkCallback]
|
||||||
|
public void on_set_color_clicked (Gtk.Button button) {
|
||||||
|
if (initialized) {
|
||||||
|
Gdk.RGBA rgba = keyboard_color.get_rgba ();
|
||||||
|
|
||||||
|
set_keyboard_color (rgba);
|
||||||
|
settings.set_string ("keyboard-color", rgba.to_string ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
src/gui.vala
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The GUI namespace contains a GTK based interface to interact with the TUF laptop
|
||||||
|
*/
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application class
|
||||||
|
*/
|
||||||
|
public class TUFManagerApp : Gtk.Application {
|
||||||
|
/**
|
||||||
|
* The main application window
|
||||||
|
*/
|
||||||
|
private MainWindow window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the application and set it's id
|
||||||
|
*/
|
||||||
|
public TUFManagerApp () {
|
||||||
|
application_id = "cl.cromer.tuf.manager";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run when the application is activated
|
||||||
|
*/
|
||||||
|
public override void activate () {
|
||||||
|
window = new MainWindow (this);
|
||||||
|
window.icon = new Gtk.Image.from_resource ("/cl/cromer/tuf-manager/pixdata/tuf-manager.png").get_pixbuf ();
|
||||||
|
window.show_all ();
|
||||||
|
window.initialize ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run when the application starts
|
||||||
|
*/
|
||||||
|
public override void startup () {
|
||||||
|
Intl.textdomain (GETTEXT_PACKAGE);
|
||||||
|
Intl.setlocale (LocaleCategory.ALL, "");
|
||||||
|
base.startup ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
src/main.vala.in
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The entry point to the TUF Manager application
|
||||||
|
*
|
||||||
|
* @param args Arguments passed from the command line
|
||||||
|
* @return Returns the status from the application
|
||||||
|
*/
|
||||||
|
public static int main (string[] args) {
|
||||||
|
var application = new @APP@.TUFManagerApp ();
|
||||||
|
try {
|
||||||
|
application.register ();
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
if (application.get_is_remote ()) {
|
||||||
|
stderr.printf ("Error: %s\n", _ ("Another instance of TUF Manager is already running!"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return application.run (args);
|
||||||
|
}
|
||||||
|
}
|
154
src/meson.build
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
server_dependencies = [
|
||||||
|
dependency('glib-2.0'),
|
||||||
|
dependency('gtk+-3.0', version: '>=3.0.0'),
|
||||||
|
meson.get_compiler('c').find_library('m', required: true)
|
||||||
|
]
|
||||||
|
|
||||||
|
# if not always authenticated then polkit will be used for authentication
|
||||||
|
if not always_authenticated
|
||||||
|
server_dependencies += [dependency('polkit-gobject-1')]
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_cli
|
||||||
|
cli_dependencies = [
|
||||||
|
dependency('glib-2.0'),
|
||||||
|
dependency('gtk+-3.0', version: '>=3.0.0')
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_gui
|
||||||
|
gui_dependencies = [
|
||||||
|
dependency('glib-2.0'),
|
||||||
|
dependency('gobject-2.0'),
|
||||||
|
dependency('gtk+-3.0', version: '>=3.10.0'),
|
||||||
|
dependency('gmodule-2.0', version: '>=2.0') # gmodule-export-2.0 is needed to connect the handlers from glade ui
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
|
config_data = configuration_data()
|
||||||
|
config_data.set('VERSION', meson.project_version())
|
||||||
|
config_data.set('GETTEXT_PACKAGE', meson.project_name())
|
||||||
|
|
||||||
|
config_data_file = configure_file(
|
||||||
|
input: 'config.vala.in',
|
||||||
|
output: 'config.vala',
|
||||||
|
configuration: config_data
|
||||||
|
)
|
||||||
|
|
||||||
|
if build_cli
|
||||||
|
config_data = configuration_data()
|
||||||
|
config_data.set('APP', 'CLI')
|
||||||
|
cli_main_file = configure_file(
|
||||||
|
input: 'main.vala.in',
|
||||||
|
output: 'cli-main.vala',
|
||||||
|
configuration: config_data
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_gui
|
||||||
|
config_data = configuration_data()
|
||||||
|
config_data.set('APP', 'GUI')
|
||||||
|
gui_main_file = configure_file(
|
||||||
|
input: 'main.vala.in',
|
||||||
|
output: 'gui-main.vala',
|
||||||
|
configuration: config_data
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
error_vala_sources = files(
|
||||||
|
'error.vala'
|
||||||
|
)
|
||||||
|
|
||||||
|
# The sources containing a main function definition are separated to prevent
|
||||||
|
# conflict errors when building valadoc. valadoc doesn't like multiple entry
|
||||||
|
# points even if they are in different namespaces.
|
||||||
|
server_vala_sources_main = files(
|
||||||
|
'server-main.vala'
|
||||||
|
)
|
||||||
|
|
||||||
|
server_vala_sources = files(
|
||||||
|
'server.vala',
|
||||||
|
'server-interface.vala'
|
||||||
|
)
|
||||||
|
|
||||||
|
if build_cli
|
||||||
|
cli_vala_sources = files(
|
||||||
|
'cli.vala',
|
||||||
|
'server-interface.vala',
|
||||||
|
'common.vala'
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_gui
|
||||||
|
gui_vala_sources = files(
|
||||||
|
'gui.vala',
|
||||||
|
'gui-window.vala',
|
||||||
|
'server-interface.vala',
|
||||||
|
'common.vala'
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
server_sources = server_vala_sources
|
||||||
|
server_sources += server_vala_sources_main
|
||||||
|
server_sources += error_vala_sources
|
||||||
|
server_sources += config_data_file
|
||||||
|
|
||||||
|
if build_cli
|
||||||
|
cli_sources = cli_vala_sources
|
||||||
|
cli_sources += cli_main_file
|
||||||
|
cli_sources += error_vala_sources
|
||||||
|
cli_sources += config_data_file
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_gui
|
||||||
|
gui_sources = gui_vala_sources
|
||||||
|
gui_sources += gui_main_file
|
||||||
|
gui_sources += error_vala_sources
|
||||||
|
gui_sources += [tuf_manager_gresource]
|
||||||
|
gui_sources += config_data_file
|
||||||
|
endif
|
||||||
|
|
||||||
|
server_vala_args = []
|
||||||
|
if always_authenticated
|
||||||
|
server_vala_args += ['--define=ALWAYS_AUTHENTICATED']
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_cli
|
||||||
|
cli_vala_args = []
|
||||||
|
if always_authenticated
|
||||||
|
cli_vala_args += ['--define=ALWAYS_AUTHENTICATED']
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_gui
|
||||||
|
gui_vala_args = ['--gresources='+join_paths(meson.source_root(), 'data/ui/tuf.manager.gresource.xml')]
|
||||||
|
endif
|
||||||
|
|
||||||
|
server_exe = executable(
|
||||||
|
'tuf-server',
|
||||||
|
server_sources,
|
||||||
|
dependencies: server_dependencies,
|
||||||
|
vala_args: server_vala_args,
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('libexecdir'), meson.project_name())
|
||||||
|
)
|
||||||
|
|
||||||
|
if build_cli
|
||||||
|
cli_exe = executable(
|
||||||
|
'tuf-cli',
|
||||||
|
cli_sources,
|
||||||
|
vala_args: cli_vala_args,
|
||||||
|
dependencies: cli_dependencies,
|
||||||
|
install: true
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if build_gui
|
||||||
|
gui_exe = executable(
|
||||||
|
'tuf-gui',
|
||||||
|
gui_sources,
|
||||||
|
dependencies: gui_dependencies,
|
||||||
|
vala_args: gui_vala_args,
|
||||||
|
install: true
|
||||||
|
)
|
||||||
|
endif
|
35
src/server-interface.vala
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* This interface defines the dbus daemon provided by the server
|
||||||
|
*/
|
||||||
|
[DBus (name = "org.tuf.manager.server")]
|
||||||
|
public interface TUFServerInterface : Object {
|
||||||
|
public abstract string get_server_version () throws Error;
|
||||||
|
public abstract int get_fan_mode () throws Error, TUFError;
|
||||||
|
public abstract void set_fan_mode (int mode, BusName sender) throws Error, TUFError;
|
||||||
|
public abstract Gdk.RGBA get_keyboard_color () throws Error, TUFError;
|
||||||
|
public abstract void set_keyboard_color (Gdk.RGBA color, BusName sender) throws Error, TUFError;
|
||||||
|
public abstract int get_keyboard_mode () throws Error, TUFError;
|
||||||
|
public abstract void set_keyboard_mode (int mode, BusName sender) throws Error, TUFError;
|
||||||
|
public abstract int get_keyboard_speed () throws Error, TUFError;
|
||||||
|
public abstract void set_keyboard_speed (int speed, BusName sender) throws Error, TUFError;
|
||||||
|
public signal void procedure_finished ();
|
||||||
|
}
|
||||||
|
}
|
44
src/server-main.vala
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The server namespace contains anything releated to working as a dbus daemon
|
||||||
|
* and handling root related tasks
|
||||||
|
*/
|
||||||
|
namespace Server {
|
||||||
|
/**
|
||||||
|
* The entry point to the server launches a system dbus daemon
|
||||||
|
*
|
||||||
|
* @param args Arguments passed from the command line
|
||||||
|
* @return Returns 0 on success
|
||||||
|
*/
|
||||||
|
public static int main (string[] args) {
|
||||||
|
Bus.own_name (BusType.SYSTEM,
|
||||||
|
"org.tuf.manager.server",
|
||||||
|
BusNameOwnerFlags.NONE,
|
||||||
|
on_bus_acquired,
|
||||||
|
() => {},
|
||||||
|
() => {
|
||||||
|
stderr.printf ("Could not acquire name\n");
|
||||||
|
});
|
||||||
|
loop = new MainLoop ();
|
||||||
|
loop.run ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
517
src/server.vala
Normal file
@ -0,0 +1,517 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Chris Cromer
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Manager namespace
|
||||||
|
*/
|
||||||
|
namespace TUFManager {
|
||||||
|
/**
|
||||||
|
* The server namespace contains anything releated to working as a dbus daemon
|
||||||
|
* and handling root related tasks
|
||||||
|
*/
|
||||||
|
namespace Server {
|
||||||
|
/**
|
||||||
|
* The global instance of the server running as a dbus daemon
|
||||||
|
*/
|
||||||
|
TUFServer tuf_server;
|
||||||
|
/**
|
||||||
|
* The loop of the dbus daemon running in the background
|
||||||
|
*/
|
||||||
|
MainLoop loop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the bus after the name has been aquired
|
||||||
|
*
|
||||||
|
* @param conn The connection to register with
|
||||||
|
*/
|
||||||
|
private void on_bus_acquired (DBusConnection conn) {
|
||||||
|
try {
|
||||||
|
tuf_server = new TUFManager.Server.TUFServer ();
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
conn.register_object ("/org/tuf/manager/server", tuf_server);
|
||||||
|
}
|
||||||
|
catch (IOError e) {
|
||||||
|
stderr.printf ("Could not register service\n");
|
||||||
|
loop.quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TUF Server is a dbus service that runs in the background and uses
|
||||||
|
* root priveleges via polkit to make system changes
|
||||||
|
*/
|
||||||
|
[DBus (name = "org.tuf.manager.server")]
|
||||||
|
public class TUFServer : Object {
|
||||||
|
private Mutex locked;
|
||||||
|
private Mutex authorization;
|
||||||
|
private GenericSet<string> authorized_senders;
|
||||||
|
private MainContext context;
|
||||||
|
public signal void procedure_finished ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server class initialization
|
||||||
|
*
|
||||||
|
* @throws Error Thrown if there is a problem connecting to a dbus session or an IO error
|
||||||
|
*/
|
||||||
|
public TUFServer () throws Error {
|
||||||
|
locked = Mutex ();
|
||||||
|
authorization = Mutex ();
|
||||||
|
authorized_senders = new GenericSet<string> (str_hash, str_equal);
|
||||||
|
context = MainContext.ref_thread_default ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get authorization to run root tasks via polkit
|
||||||
|
*
|
||||||
|
* @param sender The bus that sent the request
|
||||||
|
* @throws Error Thrown if there is a problem connecting to a dbus session or an IO error
|
||||||
|
*/
|
||||||
|
private async bool get_authorization (BusName sender) throws Error {
|
||||||
|
#if ALWAYS_AUTHENTICATED
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
bool authorized = false;
|
||||||
|
authorization.lock ();
|
||||||
|
bool fast_authorized = authorized_senders.contains (sender);
|
||||||
|
authorization.unlock ();
|
||||||
|
if (fast_authorized) {
|
||||||
|
var idle = new IdleSource ();
|
||||||
|
idle.set_priority (Priority.DEFAULT);
|
||||||
|
idle.set_callback (() => {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
idle.attach (context);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Polkit.Authority authority = yield Polkit.Authority.get_async ();
|
||||||
|
Polkit.Subject subject = new Polkit.SystemBusName (sender);
|
||||||
|
var result = yield authority.check_authorization (
|
||||||
|
subject,
|
||||||
|
"org.tuf.manager.save",
|
||||||
|
null,
|
||||||
|
Polkit.CheckAuthorizationFlags.ALLOW_USER_INTERACTION);
|
||||||
|
authorized = result.get_is_authorized ();
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
/*if (!authorized) {
|
||||||
|
stderr.printf ("%s\n", _ ("Authentication failed!"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stderr.printf ("%s\n", _ ("Authentication passed!"));
|
||||||
|
}*/
|
||||||
|
return authorized;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the currently running server
|
||||||
|
*
|
||||||
|
* @return Returns a string containing the version
|
||||||
|
* @throws Error Thrown if there is a problem connecting to a dbus session or an IO error
|
||||||
|
*/
|
||||||
|
public string get_server_version () throws Error {
|
||||||
|
return VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current fan mode
|
||||||
|
*
|
||||||
|
* @return Returns the current fan mode
|
||||||
|
* @throws Error Thrown if there is a problem connecting to a dbus session or an IO error
|
||||||
|
* @throws TUFError Thrown if there is a problem reading a value from the stream
|
||||||
|
*/
|
||||||
|
public int get_fan_mode () throws Error, TUFError {
|
||||||
|
var stream = FileStream.open (THERMAL_PATH, "r");
|
||||||
|
if (stream == null) {
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var line = stream.read_line ();
|
||||||
|
if (line == null) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File is empty!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var mode = int.parse (line);
|
||||||
|
if (mode < 0 || mode > 2) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File contains invalid value!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a new fan mode
|
||||||
|
*
|
||||||
|
* * 1 - normal mode
|
||||||
|
* * 2 - boost mode
|
||||||
|
* * 3 - silent mode
|
||||||
|
*
|
||||||
|
* @param mode The new mode to set
|
||||||
|
* @throws Error Thrown if there is a problem connecting to a dbus session or an IO error
|
||||||
|
* @throws TUFError Thrown if there is a problem writing a value to the stream
|
||||||
|
*/
|
||||||
|
public void set_fan_mode (int mode, BusName sender) throws Error, TUFError {
|
||||||
|
get_authorization.begin (sender, (obj, res) => {
|
||||||
|
bool authorized = false;
|
||||||
|
try {
|
||||||
|
authorized = get_authorization.end (res);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authorized) {
|
||||||
|
try {
|
||||||
|
set_fan_mode_authorized (mode, sender);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Not authorized, so let's end this
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_fan_mode_authorized (int mode, BusName sender) throws Error, TUFError {
|
||||||
|
locked.lock ();
|
||||||
|
var stream = FileStream.open (THERMAL_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode < 0 || mode > 2) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("Invalid value!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.puts (mode.to_string ());
|
||||||
|
locked.unlock ();
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gdk.RGBA get_keyboard_color () throws Error, TUFError {
|
||||||
|
string color = "#";
|
||||||
|
|
||||||
|
// Get red
|
||||||
|
var stream = FileStream.open (RED_PATH, "r");
|
||||||
|
if (stream == null) {
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var line = stream.read_line ();
|
||||||
|
if (line == null) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File is empty!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
color += line;
|
||||||
|
|
||||||
|
// Get green
|
||||||
|
stream = FileStream.open (GREEN_PATH, "r");
|
||||||
|
if (stream == null) {
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
line = stream.read_line ();
|
||||||
|
if (line == null) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File is empty!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
color += line;
|
||||||
|
|
||||||
|
// Get blue
|
||||||
|
stream = FileStream.open (BLUE_PATH, "r");
|
||||||
|
if (stream == null) {
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
line = stream.read_line ();
|
||||||
|
if (line == null) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File is empty!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
color += line;
|
||||||
|
|
||||||
|
var rgba = Gdk.RGBA ();
|
||||||
|
rgba.parse (color);
|
||||||
|
|
||||||
|
return rgba;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set_keyboard_color (Gdk.RGBA color, BusName sender) throws Error, TUFError {
|
||||||
|
get_authorization.begin (sender, (obj, res) => {
|
||||||
|
bool authorized = false;
|
||||||
|
try {
|
||||||
|
authorized = get_authorization.end (res);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authorized) {
|
||||||
|
try {
|
||||||
|
set_keyboard_color_authorized (color, sender);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Not authorized, so let's end this
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_keyboard_color_authorized (Gdk.RGBA color, BusName sender) throws Error, TUFError {
|
||||||
|
locked.lock ();
|
||||||
|
|
||||||
|
var red = "%02x".printf ((uint) (Math.round (color.red * 255))).up ();
|
||||||
|
var green = "%02x".printf ((uint) (Math.round (color.green * 255))).up ();
|
||||||
|
var blue = "%02x".printf ((uint) (Math.round (color.blue * 255))).up ();
|
||||||
|
var keyboard_set = "1";
|
||||||
|
var keyboard_flags = "2a";
|
||||||
|
|
||||||
|
var stream = FileStream.open (RED_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (red);
|
||||||
|
|
||||||
|
stream = FileStream.open (GREEN_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (green);
|
||||||
|
|
||||||
|
stream = FileStream.open (BLUE_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (blue);
|
||||||
|
|
||||||
|
stream = FileStream.open (KEYBOARD_FLAGS_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (keyboard_flags);
|
||||||
|
|
||||||
|
stream = FileStream.open (KEYBOARD_SET_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (keyboard_set);
|
||||||
|
|
||||||
|
locked.unlock ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int get_keyboard_mode () throws Error, TUFError {
|
||||||
|
var stream = FileStream.open (KEYBOARD_MODE_PATH, "r");
|
||||||
|
if (stream == null) {
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var line = stream.read_line ();
|
||||||
|
if (line == null) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File is empty!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var mode = int.parse (line);
|
||||||
|
if (mode < 0 || mode > 3) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File contains invalid value!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set_keyboard_mode (int mode, BusName sender) throws Error, TUFError {
|
||||||
|
get_authorization.begin (sender, (obj, res) => {
|
||||||
|
bool authorized = false;
|
||||||
|
try {
|
||||||
|
authorized = get_authorization.end (res);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authorized) {
|
||||||
|
try {
|
||||||
|
set_keyboard_mode_authorized (mode, sender);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Not authorized, so let's end this
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_keyboard_mode_authorized (int mode, BusName sender) throws Error, TUFError {
|
||||||
|
locked.lock ();
|
||||||
|
var keyboard_set = "1";
|
||||||
|
var keyboard_flags = "2a";
|
||||||
|
|
||||||
|
var stream = FileStream.open (KEYBOARD_MODE_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode < 0 || mode > 3) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("Invalid value!"));
|
||||||
|
}
|
||||||
|
stream.puts (mode.to_string ());
|
||||||
|
|
||||||
|
stream = FileStream.open (KEYBOARD_FLAGS_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (keyboard_flags);
|
||||||
|
|
||||||
|
stream = FileStream.open (KEYBOARD_SET_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (keyboard_set);
|
||||||
|
|
||||||
|
locked.unlock ();
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int get_keyboard_speed () throws Error, TUFError {
|
||||||
|
var stream = FileStream.open (KEYBOARD_SPEED_PATH, "r");
|
||||||
|
if (stream == null) {
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var line = stream.read_line ();
|
||||||
|
if (line == null) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File is empty!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var mode = int.parse (line);
|
||||||
|
if (mode < 0 || mode > 2) {
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("File contains invalid value!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set_keyboard_speed (int speed, BusName sender) throws Error, TUFError {
|
||||||
|
get_authorization.begin (sender, (obj, res) => {
|
||||||
|
bool authorized = false;
|
||||||
|
try {
|
||||||
|
authorized = get_authorization.end (res);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authorized) {
|
||||||
|
try {
|
||||||
|
set_keyboard_speed_authorized (speed, sender);
|
||||||
|
}
|
||||||
|
catch (TUFError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Not authorized, so let's end this
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_keyboard_speed_authorized (int speed, BusName sender) throws Error, TUFError {
|
||||||
|
locked.lock ();
|
||||||
|
var keyboard_set = "1";
|
||||||
|
var keyboard_flags = "2a";
|
||||||
|
|
||||||
|
var stream = FileStream.open (KEYBOARD_SPEED_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (speed < 0 || speed > 2) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.INVALID_VALUE (_ ("Invalid value!"));
|
||||||
|
}
|
||||||
|
stream.puts (speed.to_string ());
|
||||||
|
|
||||||
|
stream = FileStream.open (KEYBOARD_FLAGS_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (keyboard_flags);
|
||||||
|
|
||||||
|
stream = FileStream.open (KEYBOARD_SET_PATH, "w");
|
||||||
|
if (stream == null) {
|
||||||
|
locked.unlock ();
|
||||||
|
throw new TUFError.STREAM (_ ("Failed to open stream!"));
|
||||||
|
}
|
||||||
|
stream.puts (keyboard_set);
|
||||||
|
|
||||||
|
locked.unlock ();
|
||||||
|
procedure_finished ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|