From bf823316a5bc454e7abd4073165fc79545f3a60a Mon Sep 17 00:00:00 2001
From: Htylol <dixperm909@yandex.ru>
Date: Sun, 2 Mar 2025 01:36:10 +0500
Subject: [PATCH] The display in time can now display only hours and minutes,
 or days, hours, minutes, or nothing. Display hours and minutes turned on by
 default

---
 data_from_portwine/locales/PortProton.pot     |  8 ++++-
 .../locales/es/LC_MESSAGES/PortProton.po      |  8 ++++-
 .../locales/ru/LC_MESSAGES/PortProton.po      | 10 ++++--
 data_from_portwine/scripts/functions_helper   | 35 ++++++++++++-------
 data_from_portwine/scripts/start.sh           | 12 +++++--
 5 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/data_from_portwine/locales/PortProton.pot b/data_from_portwine/locales/PortProton.pot
index 9284ab99..94323242 100644
--- a/data_from_portwine/locales/PortProton.pot
+++ b/data_from_portwine/locales/PortProton.pot
@@ -7,7 +7,7 @@
 msgid   ""
 msgstr  "Project-Id-Version: PACKAGE VERSION\n"
         "Report-Msgid-Bugs-To: \n"
-        "POT-Creation-Date: 2025-02-27 20:05+0500\n"
+        "POT-Creation-Date: 2025-03-02 01:22+0500\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"
@@ -1415,6 +1415,12 @@ msgid   "If downloading steam covers is enabled, they will be downloaded and "
         "is unavailable for some reason)"
 msgstr  ""
 
+msgid   "Show in hours and minutes"
+msgstr  ""
+
+msgid   "Show in days, hours, minutes"
+msgstr  ""
+
 msgid   "Recommended value"
 msgstr  ""
 
diff --git a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po
index ba5e9eb5..17dc96cb 100644
--- a/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po
+++ b/data_from_portwine/locales/es/LC_MESSAGES/PortProton.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-27 20:05+0500\n"
+"POT-Creation-Date: 2025-03-02 01:22+0500\n"
 "PO-Revision-Date: 2024-11-13 08:18+0500\n"
 "Last-Translator: \n"
 "Language-Team: \n"
@@ -1844,6 +1844,12 @@ msgstr ""
 "crearán. (La desactivación se proporciona en los casos en que su descarga no "
 "esté disponible por algún motivo)"
 
+msgid "Show in hours and minutes"
+msgstr ""
+
+msgid "Show in days, hours, minutes"
+msgstr ""
+
 msgid "Recommended value"
 msgstr ""
 
diff --git a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po
index be108cfb..6c260041 100644
--- a/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po
+++ b/data_from_portwine/locales/ru/LC_MESSAGES/PortProton.po
@@ -7,8 +7,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-27 20:05+0500\n"
-"PO-Revision-Date: 2025-02-27 20:06+0500\n"
+"POT-Creation-Date: 2025-03-02 01:22+0500\n"
+"PO-Revision-Date: 2025-03-02 01:22+0500\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "Language: ru_RU\n"
@@ -1832,6 +1832,12 @@ msgstr ""
 "создаваться. (Отключение предусмотрено в тех случаях, когда их скачивание по "
 "каким-то причинам недоступно)"
 
+msgid "Show in hours and minutes"
+msgstr "Отображать в часах и минутах"
+
+msgid "Show in days, hours, minutes"
+msgstr "Отображать в днях, часах и минутах"
+
 msgid "Recommended value"
 msgstr "Рекомендуемое значение"
 
diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper
index 2462f216..3f73699c 100755
--- a/data_from_portwine/scripts/functions_helper
+++ b/data_from_portwine/scripts/functions_helper
@@ -1248,13 +1248,15 @@ create_name_desktop () {
 
 # Конвертация секунд в дни, часы, минуты
 seconds_to_time () {
-    [[ ! $DESKTOP_WITH_TIME == enabled ]] && return 0
+    [[ $DESKTOP_WITH_TIME == "disabled" ]] && return 0
     [[ -z $1 ]] && return 0
     local seconds days hours minutes
     seconds=$1
 
-    days=$((seconds / (60 * 60 * 24)))
-    seconds=$((seconds % (60 * 60 * 24)))
+    if [[ $DESKTOP_WITH_TIME == "posnumber2" ]] ; then
+        days=$((seconds / (60 * 60 * 24)))
+        seconds=$((seconds % (60 * 60 * 24)))
+    fi
 
     hours=$((seconds / (60 * 60)))
     seconds=$((seconds % (60 * 60)))
@@ -1292,7 +1294,7 @@ seconds_to_time () {
         if [[ -z $days ]] || [[ -z $hours ]] ; then
             days=${days//","/}
         fi
-        if [[ -z $days ]] && [[ -z $hours ]] ; then
+        if [[ -z $minutes ]] ; then
             minutes="${translations[less than a minute]}"
         fi
     elif [[ $minutes =~ ^1$ ]] ; then
@@ -1305,7 +1307,11 @@ seconds_to_time () {
         minutes="$minutes ${translations[minutes]}"
     fi
 
-    echo -e "<b>\n${translations[Time spent]}: $days$hours$minutes</b>"
+    if [[ $DESKTOP_WITH_TIME == "posnumber1" ]] ; then
+        echo -e "<b>\n${translations[Time spent]}: $hours$minutes</b>"
+    elif [[ $DESKTOP_WITH_TIME == "posnumber2" ]] ; then
+        echo -e "<b>\n${translations[Time spent]}: $days$hours$minutes</b>"
+    fi
 }
 
 combobox_fix () {
@@ -6006,10 +6012,10 @@ gui_userconf () {
         GPU_VAR="disabled"
     fi
 
-    if [[ -n "$DESKTOP_WITH_TIME" ]] \
-    && [[ "$DESKTOP_WITH_TIME" != "disabled" ]]
-    then
-        DESKTOP_WITH_TIME="enabled"
+    if [[ $DESKTOP_WITH_TIME == "posnumber1" ]] ; then
+        DESKTOP_WITH_TIME=${translations[Show in hours and minutes]}
+    elif [[ $DESKTOP_WITH_TIME == "posnumber2" ]] ; then
+        DESKTOP_WITH_TIME=${translations[Show in days, hours, minutes]}
     else
         DESKTOP_WITH_TIME="disabled"
     fi
@@ -6033,9 +6039,9 @@ gui_userconf () {
         YAD_DPI_VAR="disabled"
     fi
 
-    if [[ $GUI_THEME == default ]] ; then GUI_THEME=${translations[default]}
-    elif [[ $GUI_THEME == compact ]] ; then GUI_THEME=${translations[compact]}
-    elif [[ $GUI_THEME == classic ]] ; then GUI_THEME=${translations[classic]}
+    if [[ $GUI_THEME == "default" ]] ; then GUI_THEME=${translations[default]}
+    elif [[ $GUI_THEME == "compact" ]] ; then GUI_THEME=${translations[compact]}
+    elif [[ $GUI_THEME == "classic" ]] ; then GUI_THEME=${translations[classic]}
     fi
 
     if command -v gsettings &>/dev/null ; then
@@ -6055,7 +6061,7 @@ gui_userconf () {
     --field="${translations[Choice wine audio driver]}!${translations[Fixes sound popling if choice alsa]} :CB" "$(combobox_fix --disabled "$SOUND_DRIVER_VAR" "alsa!oss!pulse")" \
     --field="${translations[Select PortProton theme]}!${translations[Allows you to select a theme for PortProton]} :CB" "$(combobox_fix "$GUI_THEME" "${translations[default]}!${translations[compact]}!${translations[classic]}")" \
     --field="${translations[Select gtk theme]}!${translations[Allows you to select a theme for GTK.]} :CB" "$(combobox_fix "$GTK_THEME" "${YAD_GTK_THEME}Adwaita:${translations[light]}!Adwaita:${translations[dark]}!${translations[default]}")" \
-    --field="${translations[Time display]}!${translations[Displays time spent in an application or game]} :CB" "$(combobox_fix --disabled "$DESKTOP_WITH_TIME" "enabled")" \
+    --field="${translations[Time display]}!${translations[Displays time spent in an application or game]} :CB" "$(combobox_fix --disabled "$DESKTOP_WITH_TIME" "${translations[Show in hours and minutes]}!${translations[Show in days, hours, minutes]}")" \
     --field="${translations[Sort shortcuts by time]}!${translations[This setting sorts the shortcuts in the main menu depending on the time spent in the application or game]} :CB" "$(combobox_fix --disabled "$SORT_WITH_TIME" "enabled")" \
     1> "${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" 2>/dev/null &
 
@@ -6107,6 +6113,9 @@ gui_userconf () {
             elif [[ $GTK_THEME =~ ${translations[light]} ]] ; then GTK_THEME=${GTK_THEME//${translations[light]}/light}
             elif [[ $GTK_THEME =~ ${translations[dark]} ]] ; then GTK_THEME=${GTK_THEME//${translations[dark]}/dark}
             fi
+            if [[ $DESKTOP_WITH_TIME == "${translations[Show in hours and minutes]}" ]] ; then DESKTOP_WITH_TIME="posnumber1"
+            elif [[ $DESKTOP_WITH_TIME == "${translations[Show in days, hours, minutes]}" ]] ; then DESKTOP_WITH_TIME="posnumber2"
+            fi
 
             edit_user_conf_from_gui PW_GPU_USE PW_WINE_DPI_VALUE PW_SOUND_DRIVER_USE GUI_THEME GTK_THEME DESKTOP_WITH_TIME SORT_WITH_TIME
             restart_pp
diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh
index e0b7b89b..29370239 100755
--- a/data_from_portwine/scripts/start.sh
+++ b/data_from_portwine/scripts/start.sh
@@ -262,10 +262,16 @@ if [[ ! $PW_GUI_START =~ (PANED|NOTEBOOK) ]] ; then
     export PW_GUI_START="NOTEBOOK"
 fi
 
+# DESKTOP_WITH_TIME by default displays hours and minutes
+if [[ -z $DESKTOP_WITH_TIME ]] ; then
+    echo 'export DESKTOP_WITH_TIME="posnumber1"' >> "$USER_CONF"
+    export DESKTOP_WITH_TIME="posnumber1"
+fi
+
 # TODO:fixes_after_update
-if fixes_after_update "2372: Reset PW_WINE_DPI_VALUE in user.conf" ; then
-    sed -i '/export PW_WINE_DPI_VALUE=/d' "$USER_CONF"
-    unset PW_WINE_DPI_VALUE
+if fixes_after_update "2395: DESKTOP_WITH_TIME by default displays hours and minutes" ; then
+    DESKTOP_WITH_TIME="posnumber1"
+    edit_user_conf_from_gui DESKTOP_WITH_TIME
 fi
 
 # choose wine dpi default