diff --git a/README.command b/README.command new file mode 100644 index 0000000..424cd22 --- /dev/null +++ b/README.command @@ -0,0 +1,8 @@ +tuned_adm.py +------------ +tuned_adm.py is commandline tool for setting modes +which needs ktune and kobo packages. kobo is in repo, +ktune must be rebuilt from srpm. + +Commandline is calling ktune with 'tuned_adm.py server' +and setting it back by call 'tuned_adm.py default'. diff --git a/commands/__init__.py b/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/commands/cmd_default_mode.py b/commands/cmd_default_mode.py new file mode 100644 index 0000000..ddc928e --- /dev/null +++ b/commands/cmd_default_mode.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + + +from kobo.cli import Command +import os + +class Default(Command): + """set default mode""" + enabled = True + + def options(self): + self.parser.usage = "%%prog %s" % self.normalized_name + + self.parser.add_option( + "--show-disabled", + default=False, + action="store_true", + help="show disabled workers" + ) + + + def run(self, *args, **kwargs): + os.system('service ktune stop') + os.system('service tuned stop') + diff --git a/commands/cmd_laptop_mode.py b/commands/cmd_laptop_mode.py new file mode 100644 index 0000000..6f59664 --- /dev/null +++ b/commands/cmd_laptop_mode.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + + +from kobo.cli import Command +import os + +class Laptop(Command): + """set laptop mode""" + enabled = True + + + def options(self): + self.parser.usage = "%%prog %s" % self.normalized_name + + self.parser.add_option( + "--show-disabled", + default=False, + action="store_true", + help="show disabled workers" + ) + + + def run(self, *args, **kwargs): + # this should be part of ktune + # if on wifi then switch off network card? + pass diff --git a/commands/cmd_server_mode.py b/commands/cmd_server_mode.py new file mode 100644 index 0000000..6b89c53 --- /dev/null +++ b/commands/cmd_server_mode.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + + +from kobo.cli import Command +import os + +class Server(Command): + """set server mode""" + enabled = True + + def options(self): + self.parser.usage = "%%prog %s" % self.normalized_name + + self.parser.add_option( + "--show-disabled", + default=False, + action="store_true", + help="show disabled workers" + ) + + + def run(self, *args, **kwargs): + # call ktune - need check of status + os.system('service ktune start') + # usb suspend? + diff --git a/man/tuned_adm.1 b/man/tuned_adm.1 new file mode 100644 index 0000000..8b41a8e --- /dev/null +++ b/man/tuned_adm.1 @@ -0,0 +1,45 @@ +.\"/* +.\" * All rights reserved +.\" * Copyright (C) 2009 Red Hat, Inc. +.\" * Authors: Marcela Mašláňová +.\" * +.\" * This program is free software; you can redistribute it and/or +.\" * modify it under the terms of the GNU General Public License +.\" * as published by the Free Software Foundation; either version 2 +.\" * of the License, or (at your option) any later version. +.\" * +.\" * This program is distributed in the hope that it will be useful, +.\" * but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" * GNU General Public License for more details. +.\" * +.\" * You should have received a copy of the GNU General Public License +.\" * along with this program; if not, write to the Free Software +.\" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +.\" */ +.\" +.TH TUNED_ADM "1" "9 Jul 2009" "Linux Programmer's Manual" +.SH NAME +tuned_adm \- commandline tool for setting the power-save options +.SH SYNOPSIS +.B tuned_adm +.B +.BR help ", " laptop ", " server +.br +.SH DESCRIPTION +This command line utility allows user to set profile for server or laptop. +.SH "OPTIONS" +.TP +.B help +Print out the list of commands. +.TP +.B laptop +.TP +.B server +.TP +These settings are calling ktune which set up different values for better resource consumption. + +.SH "SEE ALSO" +.SH AUTHOR +.nf +Marcela Mašláňová diff --git a/tuned_adm.py b/tuned_adm.py new file mode 100755 index 0000000..a9e0c8b --- /dev/null +++ b/tuned_adm.py @@ -0,0 +1,22 @@ +#!/usr/bin/python + +import os +import sys +import locale +from kobo.cli import * + + +from kobo.tback import * +set_except_hook() + + +import commands +CommandContainer.register_module(commands) + + +def main(argv): + parser = CommandOptionParser(command_container=CommandContainer(), default_command="help") + parser.run() + +if __name__ == "__main__": + main(sys.argv[1:])