Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Ability to change profiles using CLI #388

Open
martinszeltins opened this issue May 30, 2024 · 10 comments
Open

[Feature Request] Ability to change profiles using CLI #388

martinszeltins opened this issue May 30, 2024 · 10 comments

Comments

@martinszeltins
Copy link

martinszeltins commented May 30, 2024

Sometimes I connect to my computer via ssh and would like to be able to change the profile using the command line.

Something like this:

$ tuxedo-control-center --set-profile="Default"
$ tuxedo-control-center --set-profile="Cool and breezy"
$ tuxedo-control-center --set-profile="Powersave extreme"
@munix9
Copy link

munix9 commented May 30, 2024

It would be even better if tcc could/would adhere to the dbus specs from https://gitlab.freedesktop.org/upower/power-profiles-daemon.

Then you could even control tcc from KDE/GTK and manage it with a tool similar to powerprofilesctl.

https://pointieststick.com/2021/07/23/this-week-in-kde-power-profiles-and-a-more-polished-kickoff/
https://linuxconfig.org/how-to-manage-power-profiles-over-d-bus-with-power-profiles-daemon-on-linux

See also
#318
#373

@harridu
Copy link

harridu commented Aug 22, 2024

metoo

I would be highly interested in DBus integration as well. I mean I am sitting in front of the device, I am affected by the noisy fan, and yet I have to ask an admin to enter the root password to change the profile in TCC? Come on!

@kareltucek
Copy link

kareltucek commented Dec 12, 2024

metoo

I have been trying to figure out what the "quick and easy way" that is mentioned all over the place is, but without success.

Furthest I got to is:

gdbus call --system --dest com.tuxedocomputers.tccd \
  --object-path /com/tuxedocomputers/tccd \
  --method com.tuxedocomputers.tccd.SetTempProfile \
  -- 'performance'

However, this switches the profile for only a few seconds. Then something switches it back, so I guess that TempProfile is something different from those profiles that can be set via gui.

@martinszeltins
Copy link
Author

gdbus call --system --dest com.tuxedocomputers.tccd \
  --object-path /com/tuxedocomputers/tccd \
  --method com.tuxedocomputers.tccd.SetTempProfile \
  -- 'performance'

Oh, this is REALLY GOOD! Thank you! 🙏🏻

@fivetide
Copy link

fivetide commented Jan 8, 2025

metoo

I have been trying to figure out what the "quick and easy way" that is mentioned all over the place is, but without success.

Furthest I got to is:

gdbus call --system --dest com.tuxedocomputers.tccd \
  --object-path /com/tuxedocomputers/tccd \
  --method com.tuxedocomputers.tccd.SetTempProfile \
  -- 'performance'

However, this switches the profile for only a few seconds. Then something switches it back, so I guess that TempProfile is something different from those profiles that can be set via gui.

seems to me the ui reverts back to the previous value. overall this is pretty sad, with older feature requests for this dating back to 2020...

@brunoais
Copy link

brunoais commented Jan 8, 2025

We need to be able to send these to tuxedo-control-center and not to tccd. That's why we need a new feature.

@kareltucek
Copy link

Do we? If i recall correctly, this problem persisted for me even when I killed the tuxedo-control-center.

Can someone confirm this observation?

@fivetide
Copy link

fivetide commented Jan 8, 2025

i just tested it, you are correct. the problem persists if tuxedo-control-center is not running, only tccd.

@fivetide
Copy link

fivetide commented Jan 8, 2025

so i was able to make this work by using the same dbus-method that is used by tuxedo-control-center (com.tuxedocomputers.tccd.SetTempProfileById):

gdbus call --system --dest com.tuxedocomputers.tccd \
        --object-path /com/tuxedocomputers/tccd \
        --method com.tuxedocomputers.tccd.SetTempProfileById \
        -- '__legacy_default__'

and


gdbus call --system --dest com.tuxedocomputers.tccd \
        --object-path /com/tuxedocomputers/tccd \
        --method com.tuxedocomputers.tccd.SetTempProfileById \
        -- '__legacy_cool_and_breezy__'

these did not revert immediately.

You can get the list of profiles using this one:


gdbus call --system --dest com.tuxedocomputers.tccd \
        --object-path /com/tuxedocomputers/tccd \
        --method com.tuxedocomputers.tccd.GetProfilesJSON

@kareltucek
Copy link

Thanks!

Here is a user friendly wrapper:

#!/bin/bash

function help() {
    echo "Usage: $0 list              # List all profiles with IDs"
    echo "       $0 set <profile>     # Set profile by name or ID"
}

function listProfiles() {
    gdbus call --system --dest com.tuxedocomputers.tccd \
            --object-path /com/tuxedocomputers/tccd \
            --method com.tuxedocomputers.tccd.GetProfilesJSON |
            sed "s/^[(]'//g;s/',)$//g"
}

function setProfileById() {
    gdbus call --system --dest com.tuxedocomputers.tccd \
            --object-path /com/tuxedocomputers/tccd \
            --method com.tuxedocomputers.tccd.SetTempProfileById \
            "$1"
}

function setProfile() {
    local profile="$1"
    if [ -z "$profile" ]; then
        help
        exit 1
    fi
    
    # Try to find profile by ID first
    local FOUND_ID=$(listProfiles | 
        jq -r --arg id "$profile" '.[] | select(.id == $id) | .id')
    
    # If not found by ID, try by name
    if [ -z "$FOUND_ID" ]; then
        FOUND_ID=$(listProfiles | 
            jq -r --arg name "$profile" '.[] | select(.name == $name) | .id')
    fi
    
    if [ -z "$FOUND_ID" ]; then
        echo "Error: Profile '$profile' not found"
        echo "Available profiles:"
        $0 list
        exit 1
    fi
    
    setProfileById "$FOUND_ID"
}

case "$1" in
    list)
        listProfiles | jq -r '.[] | select(.id != null) | [.id, .name] | @tsv' |
            column -t -s $'\t'
        ;;
    set)
        setProfile "$2"
        ;;
    *)
        help
        ;;
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants