Индикатор громкости в KDE

Кароче, когда нажимаешь на клаве крутилку громкости появляется говно

2zlymu95txq11

Туда бы хотя бы отображение процентов добавить, но хуй там, настроек на это нет. Пользователи винды ищут сторонее решение, попутно ставят яндекс бар. Пользователи макоси говорят НИНУЖНО. В линуксе ебутся в консоль.

Кароче, эта хуйнюшка называется OSD (Configuring On Screen Display) Её настройки лежат вот тут:

/usr/share/plasma/look-and-feel/org.kde.breath2.desktop/contents/osd

org.kde.breath2.desktop — это название темы, там может быть org.kde.breeze.desktop ну и так далее, я меняю активную тему, у меня breath2

Там нужно подкрутить файлы OsdItem.qml и Osd.qml Это по сути и есть настройки этого виджета. Можно много крутить, я в итоге сделал так

soundBar OSD

Сначала бекап

sudo cp OsdItem.qml OsdItem_back.qml 
dddsudo cp Osd.qml Osd_back.qml

Для этого надо в OsdItem.qml прописать такое

/* THIS IS A MODIFIED VERSION
 *
 * Copyright 2014 Martin Klapetek <mklapetek@kde.org> (Original)
 * Copyright 2020 Fedor Sorokin20 Fedor Sorokin* Thanks to Chris Holland <zrenfire@gmail.com> for inspiration.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 2.4
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtra
import QtQuick.Window 2.2

Item {
    property QtObject rootItem
    //Use a Medium Size icon (Smaller than Original)
    property int iconWidth: units.iconSizes.medium
    //Variable to use for padding (1/10 icon size)
    property int spacer: Math.round(units.iconSizes.medium/10)
    //Determine a suitable fixed width for progress bar based on screen width
    property int progressBarWidth: Math.round(Screen.width/1250)*100
    //Width of label displaying percentage
    property int labelWidthP: labelMetricsP.boundingRect.width
    //Width of label showing text
    property int labelWidthT: labelMetricsT.boundingRect.width
    //Width of OSD based on Icon + Progress Bar + Progress Text + Padding
    property int itemWidthP: iconWidth + spacer*3 + progressBarWidth + labelWidthP
    //Width of OSD based on Icon + Message Text + Padding
    property int itemWidthT: iconWidth + spacer*3 + labelWidthT

    //Set OSD height to the height of a medium size icon
    height: iconWidth
    //Set OSD width as determined above depending on whether progress or message is shown
    width: rootItem.showingProgress ? itemWidthP : ((itemWidthP > itemWidthT) ? itemWidthP : itemWidthT)

    //Determine how wide the percentage label needs to be
    TextMetrics {
        id: labelMetricsP
        font: label.font
        text: "000."
    }

    //Determine how wide the message label needs to be
    TextMetrics {
        id: labelMetricsT
        font: label.font
        text: rootItem.osdValue ? rootItem.osdValue : ""
    }

    //Set icon size as determined above
    PlasmaCore.IconItem {
        id: icon
        height: parent.height
        width: iconWidth
        source: rootItem.icon
    }

    //Set Progress Bar Size, Position, and Value
    PlasmaComponents.ProgressBar {
        id: progressBar
        width: progressBarWidth
        height: parent.height
        x: iconWidth + spacer*2
        visible: rootItem.showingProgress
        minimumValue: 0
        maximumValue: 100
        value: Number(rootItem.osdValue)
    }

    //Set Text Size, Position, and Value depending on whether progress or message is shown
    PlasmaExtra.Heading {
        id: label
        x: rootItem.showingProgress ? (itemWidthP - labelWidthP) : (iconWidth + spacer)
        width: rootItem.showingProgress ? labelWidthP : (rootItem.width - label.x - spacer*2)
        height: parent.height
        visible: true
        text: rootItem.showingProgress ? rootItem.osdValue : (rootItem.osdValue ? rootItem.osdValue : "")
        horizontalAlignment: Text.AlignHCenter
        maximumLineCount: 1
        elide: Text.ElideLeft
        minimumPointSize: theme.defaultFont.pointSize
        fontSizeMode: Text.HorizontalFit
    }
}

В Osd.qml надо прописать

/* THIS IS A MODIFIED VERSION
 *
 * Copyright 2014 Martin Klapetek <mklapetek@kde.org> (Original)
 * Copyright 2020 Fedor Sorokin (Changes)
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 2.0
import QtQuick.Window 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtra

PlasmaCore.Dialog {
    id: root
    location: PlasmaCore.Types.Floating
    type: PlasmaCore.Dialog.OnScreenDisplay
    outputOnly: true

    // The X11BypassWindowManagerHint flag stops KWin from forcibly re-centering the OSD.
    flags: Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint

    property int xPos: Math.round(Screen.width/2  - width / 2)
    property int yPos: Math.round(Screen.height/2)

    x: xPos
    y: yPos

    // OSD Timeout in msecs - how long it will stay on the screen
    property int timeout: 1200
    // This is either a text or a number, if showingProgress is set to true,
    // the number will be used as a value for the progress bar
    property var osdValue
    // Icon name to display
    property string icon
    // Set to true if the value is meant for progress bar,
    // false for displaying the value as normal text
    property bool showingProgress: false

    mainItem: OsdItem {
        rootItem: root
    }
}

После этого надо либо перезайти, либо перезапустить плазму

kquitapp5 plasmashell && kstart5 plasmashell

В общем то и всё, но это благополучно может похериться при апдейте. Чтобы всё было чётенько, надо создать свою тему с этими изменениями и применить её.

cp -r  /usr/share/plasma/look-and-feel/org.kde.breath2.desktop  ~/.local/share/plasma/look-and-feel/wtf.kde.breath2-m.desktop

Потом собсно в ~/.local/share/plasma/look-and-feel/wtf.kde.breath2-m.desktop Надо отредактировать metadata.desktop metadata.json

[Desktop Entry]
Comment=Rework of rework of Manjaro Breath theme
Encoding=UTF-8
Keywords=Desktop;Workspace;Appearance;Look and Feel;Logout;Lock;Suspend;Shutdown;Hibernate;
Keywords[en_GB]=Desktop;Workspace;Appearance;Look and Feel;Logout;Lock;Suspend;Shutdown;Hibernate;
Name=Breath2-m
Name[en_GB]=Breath2-m
Type=Service

X-KDE-ServiceTypes=Plasma/LookAndFeel
X-KDE-PluginInfo-Author=Fedor Sorokin
X-KDE-PluginInfo-Email=livsant123@gmail.com
X-KDE-PluginInfo-License=GPLv2+
X-KDE-PluginInfo-Name=wtf.kde.breath2-m.desktop
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Website=https://manjaro.org/
X-KDE-fallbackPackage=org.kde.breeze.desktop
X-Plasma-MainScript=defaults


{
    "KPlugin": {
        "Authors": [
            {
                "Email": "livsant123@gmail.com",
                "Name": "Fedor Sorokin"
            }
        ],
        "Description": "Rework of rework of Manjaro Breath theme",
        "Id": "wtf.kde.breath2-m.desktop",
        "License": "GPLv2+",
        "Name": "Breath2-m",
        "Name[en_GB]": "Breath2-m",
        "ServiceTypes": [
            "Plasma/LookAndFeel"
        ],
        "Version": "0.1.0",
        "Website": "https://manjaro.org/"
    },
    "Keywords": "Desktop;Workspace;Appearance;Look and Feel;Logout;Lock;Suspend;Shutdown;Hibernate;",
    "Keywords[en_GB]": "Desktop;Workspace;Appearance;Look and Feel;Logout;Lock;Suspend;Shutdown;Hibernate;",
    "X-KDE-fallbackPackage": "wtf.kde.breath2-m.desktop",
    "X-Plasma-MainScript": "defaults"
}

Тема появится в списке тем в настройках. Всё можно её пилить.

Screenshot 20200627 011151

Не сказать, что всё это охуеть какое интересное приключение, но вообще очень круто, что можно всё, что угодно настраивать.

Tags
Thu Jan 01 1970 00:00:00 GMT+0000 (Coordinated Universal Time)

Written by Fedor

© 2023