settings: check if terminal supports window title once
This commit is contained in:
@@ -616,9 +616,23 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
|
|||||||
p.add("media_library_sort_by_mtime", yes_no(
|
p.add("media_library_sort_by_mtime", yes_no(
|
||||||
media_library_sort_by_mtime, false
|
media_library_sort_by_mtime, false
|
||||||
));
|
));
|
||||||
p.add("enable_window_title", yes_no(
|
p.add("enable_window_title", [this]() {
|
||||||
set_window_title, true
|
// Consider this variable only if TERM variable is available
|
||||||
));
|
// and we're not in emacs terminal nor tty (through any wrapper
|
||||||
|
// like screen).
|
||||||
|
auto term = getenv("TERM");
|
||||||
|
if (term != nullptr
|
||||||
|
&& strstr(term, "linux") == nullptr
|
||||||
|
&& strncmp(term, "eterm", const_strlen("eterm")))
|
||||||
|
return yes_no(set_window_title, true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_window_title = false;
|
||||||
|
return option_parser::worker([](std::string) {}, [] {
|
||||||
|
std::clog << "Terminal doesn't support window title, skipping 'enable_window_title'.\n";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}());
|
||||||
p.add("search_engine_default_search_mode", assign_default<unsigned>(
|
p.add("search_engine_default_search_mode", assign_default<unsigned>(
|
||||||
search_engine_default_search_mode, 1, [](unsigned v) {
|
search_engine_default_search_mode, 1, [](unsigned v) {
|
||||||
boundsCheck(v, 1u, 3u);
|
boundsCheck(v, 1u, 3u);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
void windowTitle(const std::string &status)
|
void windowTitle(const std::string &status)
|
||||||
{
|
{
|
||||||
if (strcmp(getenv("TERM"), "linux") && Config.set_window_title)
|
if (Config.set_window_title)
|
||||||
std::cout << "\033]0;" << status << "\7" << std::flush;
|
std::cout << "\033]0;" << status << "\7" << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user