From b199afb4922671c7c2620a188cf035c536f2b636 Mon Sep 17 00:00:00 2001 From: Sergey Kalinin Date: Fri, 30 Aug 2019 17:29:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B3=D0=BB=D0=B0=D1=81=D0=BD=D0=BE=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D0=B0=20XDG.=20=D0=94?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=86=D0=B5=D1=81=D1=81=20=D0=BA=D0=BE=D0=BF=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D1=83=D1=89=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B8=D1=85=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + rac_gui.tcl | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b6f341b..8615b3a 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,4 @@ http://nuk-svk.ru/soft/rac-gui/ Иконки взяты с сайта https://www.iconsdb.com/royal-blue-icons/ + diff --git a/rac_gui.tcl b/rac_gui.tcl index 5447115..277ca5e 100755 --- a/rac_gui.tcl +++ b/rac_gui.tcl @@ -20,17 +20,42 @@ package require msgcat # Устанавливаем текущий каталог set dir(root) [pwd] -# Устанавливаем рабочий каталог, если его нет то создаём -set dir(work) [file join $env(HOME) .rac_gui] -if {[file exists $dir(work)] == 0 } { +# Устанавливаем рабочий каталог, если его нет то создаём. +# Согласно спецификации XDG проверяем наличие переменных и каталогов +if [info exists env(XDG_CONFIG_HOME)] { + set dir(work) [file join $env(XDG_CONFIG_HOME) rac_gui] +} elseif [file exists [file join $env(HOME) .config]] { + set dir(work) [file join $env(HOME) .config rac_gui] +} else { + set dir(work) [file join $env(HOME) .rac_gui] +} + +if {[file exists $dir(work)] == 0} { file mkdir $dir(work) } +# Проверяем старые конфиги и при наличии переносим +if {[file exists [file join $env(HOME) .rac_gui]] ==1 && $dir(work) ne [file join $env(HOME) .rac_gui]} { + cd [file join $env(HOME) .rac_gui] + foreach f [glob -type f *] { + if {![file exists [file join $dir(work) $f]]} { + puts "File copy - [file copy $f $dir(work)]" + file rename $f [list $f old] + } + } + cd $env(HOME) + #file rename -force [file join $env(HOME) .rac_gui] [file join $env(HOME) .rac_gui.old] + file delete -force [file join $env(HOME) .rac_gui] +} + + +puts "Work dir is $dir(work)" + # каталог с модулями set dir(lib) "[file join $dir(root) lib]" # загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный if {[file exists [file join $dir(work) rac_gui.cfg]] ==0} { - file copy [file join [pwd] rac_gui.cfg] [file join $dir(work) rac_gui.cfg] + file copy [file join $dir(root) rac_gui.cfg] [file join $dir(work) rac_gui.cfg] } source [file join $dir(work) rac_gui.cfg] @@ -110,3 +135,5 @@ if [file exists [file join $dir(work) 1c_srv_new.cfg]] { puts $servers_list } + +