system.cpp 827 Bytes
#include "system.h"

void System::setIP(System::IPData &data)
{
    QString ifconfig = QString("ifconfig eth0 %1 netmask %2 up").arg(data.address, data.netmask);
    QString route = QString("route del default; route add default gw %1").arg(data.gateway);

    system(ifconfig.toLocal8Bit().constData());
    system(route.toLocal8Bit().constData());
}

void System::setBacklight(int level)
{
    QString command = QString("echo %1 > /sys/class/backlight/backlight_lvds.19/brightness").arg(level);
    system(command.toLocal8Bit().constData());
}

void System::setVolume(int percentage)
{
    static int last = -1;

    if (percentage == last)
        return;

    last = percentage;

    QString command = QString("/usr/bin/amixer -c 0 sset 'PCM',0 %1% %1% on").arg(percentage);
    system(command.toLocal8Bit().constData());
}