diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper
index 5b2f7523..c67060cf 100755
--- a/data_from_portwine/scripts/functions_helper
+++ b/data_from_portwine/scripts/functions_helper
@@ -774,7 +774,61 @@ debug_timer () {
print_warning "It took $DIFF milliseconds"
fi
fi
- return 0
+}
+
+search_desktop_file () {
+ # Поиск нужного .desktop файла по $portwine_exe, чтобы внести изменения в него.
+ for desktop_file in "${PORT_WINE_PATH}"/* ; do
+ if [[ $desktop_file =~ .desktop ]] ; then
+ if [[ ! $desktop_file =~ (/PortProton|/readme) ]] ; then
+ while IFS= read -r line ; do
+ if [[ $line =~ ^Exec= ]] ; then
+ if check_flatpak ; then
+ EXEC_DESKTOP=${line//Exec=flatpak run ru.linux_gaming.PortProton /}
+ else
+ EXEC_DESKTOP=${line//Exec=env \"${PORT_SCRIPTS_PATH}\/start.sh\" /}
+ fi
+ EXEC_DESKTOP_NEW="${EXEC_DESKTOP//\"/}"
+ fi
+
+ if [[ $line =~ ^#Time= ]] ; then
+ if [[ $portwine_exe == "$EXEC_DESKTOP_NEW" ]] ; then
+ TIME_CURRENT=${line//#Time=/}
+ if [[ ! $TIME_CURRENT =~ [0-9]+ ]] ; then
+ TIME_CURRENT="0"
+ sed -i '/^#Time=/d' "$desktop_file"
+ echo "#Time=0" >> "$desktop_file"
+ fi
+ fi
+ fi
+ done < "$desktop_file"
+ if [[ -n $PW_TIME_IN_GAME ]] ; then
+ TIME_TOTAL=$(( TIME_CURRENT + PW_TIME_IN_GAME ))
+ sed -i '/^#Time=/d' "$desktop_file"
+ echo "#Time=$TIME_TOTAL" >> "$desktop_file"
+ fi
+ fi
+ fi
+ done
+ IFS="$orig_IFS"
+}
+
+seconds_to_time () {
+ [[ -z $1 ]] && return 1
+ local seconds=$1
+
+ local minutes=$((seconds / 60))
+ local hours=$((minutes / 60))
+ local days=$((hours / 24))
+
+ local remaining_minutes=$((minutes % 60))
+ local remaining_hours=$((hours % 24))
+
+ if [[ "$LANGUAGE" == ru ]] ; then
+ echo "\n$days дней, $remaining_hours часов и $remaining_minutes минут"
+ else
+ echo "\n$days days, $remaining_hours hours and $remaining_minutes minutes"
+ fi
}
combobox_fix () {
@@ -1320,43 +1374,14 @@ stop_portwine () {
pw_auto_create_shortcut
add_in_stop_portwine
+ # То что новый трей ругается на debug_timer и search_desktop_file, так и должно быть.
debug_timer --end -s "PW_TIME_IN_GAME"
- PW_TIME_IN_GAME=$(( PW_TIME_IN_GAME / 1000 )) # в секундах
+
# В году 31536000 секунд.
# Bash у меня ещё работает с таким числом 999999999999999999999999999999999999999999999999
+ PW_TIME_IN_GAME=$(( PW_TIME_IN_GAME / 1000 )) # в секундах
- # Поиск нужного .desktop файла по $portwine_exe, чтобы внести изменения в него.
- for desktop_file in "${PORT_WINE_PATH}"/* ; do
- desktop_file_new="${desktop_file//"${PORT_WINE_PATH}/"/}"
- if [[ $desktop_file_new =~ .desktop ]] ; then
- if [[ ! $desktop_file_new =~ (PortProton|readme) ]] ; then
- while IFS= read -r line ; do
- if [[ $line =~ ^Exec= ]] ; then
- if check_flatpak ; then
- EXEC_DESKTOP=${line//Exec=flatpak run ru.linux_gaming.PortProton /}
- else
- EXEC_DESKTOP=${line//Exec=env \"${PORT_SCRIPTS_PATH}\/start.sh\" /}
- fi
- EXEC_DESKTOP_NEW="${EXEC_DESKTOP//\"/}"
- fi
- if [[ $line =~ ^#Time= ]] ; then
- WITH_TIME="1"
- TIME_CURRENT=${line//#Time=/}
- TIME_TOTAL=$(( TIME_CURRENT + PW_TIME_IN_GAME ))
- fi
- done < "$desktop_file"
- if [[ $WITH_TIME != 1 ]] ; then
- echo "#Time=0" >> "$desktop_file"
- fi
- unset WITH_TIME
- if [[ $portwine_exe == "$EXEC_DESKTOP_NEW" ]] ; then
- sed -i '/^#Time=/d' "$desktop_file"
- echo "#Time=$TIME_TOTAL" >> "$desktop_file"
- fi
- fi
- fi
- done
- IFS="$orig_IFS"
+ search_desktop_file
case "$1" in
--restart)
@@ -5152,11 +5177,20 @@ gui_userconf () {
GPU_VAR="disabled"
fi
+ if [[ -n "${DESKTOPS_WITH_TIME}" ]] \
+ && [[ "${DESKTOPS_WITH_TIME}" != "disabled" ]]
+ then
+ DESKTOPS_WITH_TIME="${DESKTOPS_WITH_TIME}"
+ else
+ DESKTOPS_WITH_TIME="disabled"
+ fi
+
"${pw_yad}" --plug=$KEY_USERCONF_GUI --tabnum="2" --form --columns=1 --separator="%" --homogeneous-row \
- --gui-type-text="${PANED_GUI_TYPE_TEXT_DOWN}" --gui-type-layout="${PANED_GUI_TYPE_LAYOUT_DOWN}" \
- --field="${translations[Choose a graphics card to run the game]}!${translations[Select which video card will be used to run the game (used for all running games and programs in PortProton)]} :CB" "$(combobox_fix --disabled "${GPU_VAR}" "${GET_GPU_NAMES}")" \
- --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[Choice gui themes]}!${translations[Allows you to select a theme for PortProton]} :CB" "$(combobox_fix "${GUI_THEME}" "default!compact!classic")" \
+ --gui-type-text="$PANED_GUI_TYPE_TEXT_DOWN" --gui-type-layout="$PANED_GUI_TYPE_LAYOUT_DOWN" \
+ --field="${translations[Choose a graphics card to run the game]}!${translations[Select which video card will be used to run the game (used for all running games and programs in PortProton)]} :CB" "$(combobox_fix --disabled "$GPU_VAR" "$GET_GPU_NAMES")" \
+ --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[Choice gui themes]}!${translations[Allows you to select a theme for PortProton]} :CB" "$(combobox_fix "$GUI_THEME" "default!compact!classic")" \
+ --field="${translations[Time display]}!${translations[Displays time spent in an application or game]} :CB" "$(combobox_fix "$DESKTOPS_WITH_TIME" "enabled!disabled")" \
1> "${PW_TMPFS_PATH}/tmp_yad_userconf_set_cb" 2>/dev/null &
"${pw_yad}" --key=$KEY_USERCONF_GUI --paned --sensitive \
@@ -5192,7 +5226,8 @@ gui_userconf () {
PW_GPU_USE="${PW_ADD_SETTINGS_UC[0]}"
PW_SOUND_DRIVER_USE="${PW_ADD_SETTINGS_UC[1]}"
GUI_THEME="${PW_ADD_SETTINGS_UC[2]}"
- edit_user_conf_from_gui PW_GPU_USE PW_SOUND_DRIVER_USE GUI_THEME
+ DESKTOPS_WITH_TIME="${PW_ADD_SETTINGS_UC[3]}"
+ edit_user_conf_from_gui PW_GPU_USE PW_SOUND_DRIVER_USE GUI_THEME DESKTOPS_WITH_TIME
restart_pp
;;
esac
diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh
index 6bfd0b96..7af73a27 100755
--- a/data_from_portwine/scripts/start.sh
+++ b/data_from_portwine/scripts/start.sh
@@ -464,14 +464,6 @@ case "${PW_VULKAN_USE}" in
*) PW_DEFAULT_VULKAN_USE="$SORT_NEWEST!$SORT_STABLE!$SORT_LEGACY!$SORT_G_ZINK!$SORT_G_NINE!$SORT_OPENGL!$SORT_VULKAN" ;;
esac
-if [[ -z "${PW_COMMENT_DB}" ]] ; then
- if [[ -n "${PORTPROTON_NAME}" ]] ; then
- PW_COMMENT_DB="${translations[Launching]} $(print_wrapped "${PORTPROTON_NAME}" "50")"
- else
- PW_COMMENT_DB="${translations[Launching]} $(print_wrapped "${PORTWINE_DB}" "50")"
- fi
-fi
-
if [[ $PW_WINE_USE == PROTON_LG ]] ; then
PW_WINE_USE="${PW_PROTON_LG_VER}"
PW_DEFAULT_WINE_USE="${PW_WINE_LG_VER}${DIST_ADD_TO_GUI}!GET-OTHER-WINE"
@@ -505,6 +497,17 @@ if [[ -f "${portwine_exe}" ]] ; then
PW_SHORTCUT="${translations[DELETE SHORTCUT]}!$PW_GUI_ICON_PATH/$BUTTON_SIZE.png!${translations[Delete shortcut for select file...]}:98"
fi
+ if [[ $DESKTOPS_WITH_TIME == enabled ]] ; then
+ search_desktop_file
+ fi
+ if [[ -z "${PW_COMMENT_DB}" ]] ; then
+ if [[ -n "${PORTPROTON_NAME}" ]] ; then
+ PW_COMMENT_DB="${translations[Launching]} $(print_wrapped "${PORTPROTON_NAME}" "50")$(seconds_to_time $TIME_CURRENT)"
+ else
+ PW_COMMENT_DB="${translations[Launching]} $(print_wrapped "${PORTWINE_DB}" "50")$(seconds_to_time $TIME_CURRENT)"
+ fi
+ fi
+
export KEY_START="$RANDOM"
if [[ "${PW_GUI_START}" == "NOTEBOOK" ]] ; then
"${pw_yad}" --plug=$KEY_START --tabnum=1 --form --separator=";" ${START_GUI_TYPE} \
@@ -583,18 +586,18 @@ if [[ -f "${portwine_exe}" ]] ; then
--button="${translations[LAUNCH]}"!"$PW_GUI_ICON_PATH/$BUTTON_SIZE.png"!"${translations[Run file ...]}":106 2>/dev/null
PW_YAD_SET="$?"
fi
- [[ -n "$PW_YAD_SET" ]] && case "$PW_YAD_SET" in
+ case $PW_YAD_SET in
128)
- if [[ "${PW_GUI_START}" == "NOTEBOOK" ]] ; then
- unset PW_YAD_FORM_TAB
- fi
- unset portwine_exe KEY_START $(sed -n '/export/p' "${PORTWINE_DB_FILE}" | sed 's/\(export\|=.*\| \)//g')
- print_info "Restarting..."
- restart_pp
- ;;
+ if [[ "${PW_GUI_START}" == "NOTEBOOK" ]] ; then
+ unset PW_YAD_FORM_TAB
+ fi
+ unset portwine_exe KEY_START $(sed -n '/export/p' "${PORTWINE_DB_FILE}" | sed 's/\(export\|=.*\| \)//g')
+ print_info "Restarting..."
+ restart_pp
+ ;;
1|252)
- exit 0
- ;;
+ exit 0
+ ;;
esac
pw_yad_set_form
pw_yad_form_vulkan
@@ -864,7 +867,7 @@ if [[ -f "${PORTWINE_DB_FILE}" ]] ; then
edit_db_from_gui PW_VULKAN_USE PW_WINE_USE PW_PREFIX_NAME
fi
-[[ -n "$PW_YAD_SET" ]] && case "$PW_YAD_SET" in
+case $PW_YAD_SET in
gui_pw_reinstall_pp|open_changelog|\
128|gui_pw_update|gui_rm_portproton|\
change_loc|gui_open_scripts_from_backup|\
@@ -894,7 +897,7 @@ fi
;;
esac
-[[ -n "$PW_YAD_SET" ]] && case "$PW_YAD_SET" in
+case $PW_YAD_SET in
98) portwine_delete_shortcut ;;
100) portwine_create_shortcut ;;
DEBUG|102) portwine_start_debug ;;