여기서 KDE를 사용하지만 다른 데스크탑 환경에서도 작동하는 솔루션이있을 수 있습니다. 나는 종종 많은 창문을 다루고 있습니다. 대부분의 창에는 많은 탭이 있습니다 (예 : 탭이 많은 돌고래 창 또는 Firefox, Konsole 등). 창 제목은 현재 탭 (대부분은 대부분 도움이 됨)을 기반으로 변경되지만 너무 많은 창으로 작업 할 때 창을 약간 구성하고 수동으로 창 이름을 바꾸고 싶습니다. 응용 프로그램이 제공하는 창 제목을 재정의합니다 . 다른 탭을 구성하고 그룹화하는 데 사용한 창을 쉽게 구분할 수 있도록 하나의 Firefox 창을 “연구”로 지정하고 다른 Firefox 창을 “문서”로 지정할 수 있습니다.
이상적으로 창 제목 표시 줄을 클릭하고 쉽게 사용자 정의 이름을 지정할 수 있었지만 작동하는 한 약간 더 성가신 솔루션을 결정했습니다.
시도 wmctrl -r :SELECT: -T "Research"
했지만 일시적으로 만 작동합니다 (예 : 탭을 전환 할 때와 같이 응용 프로그램이 변경하면 제목이 되돌려집니다).
답변
나는 똑같은 문제가 있었다.
그래서 나는 단축키에 묶인 쉘 스크립트를 작성했습니다.
핫키를 누르면 현재 활성 창 (포커스가있는 창)의 창 ID를 얻습니다.
그런 다음 해당 창에 원하는 제목을 입력 할 수있는 팝업 대화 상자가 나타납니다.
그런 다음 해당 창의 이름이 변경 될 때마다 원하는 제목으로 다시 변경됩니다.
스크립트를 사용하려면 다음이 필요합니다.
-
fish
쉘
(I 오히려 bash는 사촌 배쉬보다 물고기를 쓴 나에게 두통을 제공합니다) -
kdialog
-
스크립트를 핫키에 바인딩하는 방법
(xbindkeys
, cuz을 사용 하려면 스크립트 를 작동시켜야합니다.
"[PATH TO SCRIPT]/[NAME OF SCRIPT]"
Mod4 + t
(즉, 창 키 + t)
내 /home/o1/.xbindkeysrc
)
나에게 마술 xprop 물건에 관한 정보를 준이 친구 에게 감사합니다 .
(1 년 전과 마찬가지로, 나는 오늘까지 스크립트를 작성하지 않았습니다. xD)
추신 : 어떤 초보자라도이 답을 찾고 사용법을 모른다면, 저에게 물어 보면 알려 드리겠습니다. ^^
편집 : 명령 행에서 -t
for title_i_want
및 -w
for 스위치와 함께 사용할 수 있도록 업데이트했습니다 window_id
.
스크립트는 다음과 같습니다.
#!/usr/local/bin/fish
# this block is so you can use it from the command line with -t and -w
if test "$argv" != "" -a (math (count $argv)%2 == 0)
for i in (seq 1 (count $argv))
if test $argv[$i] = '-t'
set title_i_want $argv[(math 1 + $i)]
else if test $argv[$i] = '-w'
set window_id $argv[(math 1 + $i)]
end
end
if not test $window_id
echo "YOU DIDN'T ENTER A `window_id` WITH `-w`,
SO MAKE SURE THE WINDOW YOU WANT HAS FOCUS
TWO SECONDS FROM NOW!"
sleep 2
end
end
# get the id of the currently focused window
if not test $window_id
set window_id (xprop -root _NET_ACTIVE_WINDOW | grep -P -o "0x\w+")
end
# get the title to force on that window
if not test $title_i_want
set title_i_want (kdialog --title "entitled" --inputbox "type the title you want and hit enter.
to stop renaming,
just enter nothing and hit esc")
end
# this bit is needed for a kludge that allows window renaming
set has_renamed_before "FALSE"
set interrupt_message "WAIT WAIT I WANT A TURN BLOO BLOO BLEE BLUH BLOO" # hopefully i never want to actually use that as a title xD
xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME $interrupt_message -id $window_id
# take the output of xprop
# pipe it into a while loop
# everytime it outputs a new line
# stuff it into a variable named "current_title"
xprop -spy _NET_WM_NAME -id $window_id | while read current_title
# cut off extraneous not-the-title bits of that string
set current_title (echo $current_title | grep -P -o '(?<=_NET_WM_NAME\(UTF8_STRING\) = ").*(?="\z)')
# if the current title is the interrupt message
# AND
# this script has renamed the window at least once before
# then we wanna let the new name take over
if test $current_title = $interrupt_message -a $has_renamed_before = "TRUE"
exit
# if title_i_want is an empty string, exit
else if test $title_i_want = ""
xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME "WIDNOW WILL START RENAMING ITSELF AS NORMAL" -id $window_id
exit
# otherwise just change the title to what i want
else if test $current_title != $title_i_want
xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME "$title_i_want" -id $window_id
set has_renamed_before "TRUE"
end
end
편집 : 나는 실제로이 물고기 스크립트를 더 이상 사용하지 않습니다;
루비로 다시 썼습니다.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'trollop'
opts = Trollop.options do
opt :title_i_want, "title_i_want", default: ""
opt :bluh, "write to bluh", default: nil
opt :copy_title, "copy_title", default: nil
# TODO - AUTO OPTION
opt :auto, "auto", default: nil
end
title_i_want = opts[:title_i_want]
def get_current_wid
`xprop -root _NET_ACTIVE_WINDOW`[/0x\w+/]
end
def with_current_title wid, &block
IO.popen("xprop -spy _NET_WM_NAME _NET_WM_ICON_NAME -id #{wid}") do |io|
loop do
line = io.gets
exit if line.nil?
line = line.strip
# cut off extraneous not-the-title bits of that string
current_title = line[/(?:_NET_WM_(?:ICON_)?NAME\(UTF8_STRING\) = ")(.*)("$)/, 1]
block.call current_title unless current_title.nil?
end
end
end
def get_current_title wid
IO.popen("xprop _NET_WM_NAME _NET_WM_ICON_NAME -id #{wid}") do |io|
line = io.gets.strip
# cut off extraneous not-the-title bits of that string
current_title = line[/(?:_NET_WM_(?:ICON_)?NAME\(UTF8_STRING\) = ")(.*)("$)/, 1]
return current_title unless current_title.nil?
end
end
if opts[:copy_title]
# require "muflax"
p 1
wid = get_current_wid
`echo -n '#{get_current_title wid}(WID: #{wid})'|xclip -selection c`
exit
end
if opts[:bluh]
require "muflax"
loop do
# p 1 #db
wid = get_current_wid
# p 2 #db
File.open "bluh", "a+" do |f| f.puts get_current_title wid end
while wid == get_current_wid
# puts "..." #db
sleep 1
end
end
exit
end
#> 1A - from terminal - give title_i_want
if not title_i_want.empty?
#> 1A.1 - get current wid - assume it's the terminal_wid
terminal_wid = get_current_wid
#> 1A.2 - wait for wid to change
while get_current_wid == terminal_wid
puts "focus the window you want to title «#{title_i_want}»..."
sleep 1
end
#> 1A.3 - set new wid to target TWID
TWID = get_current_wid
#> 1B - from hotkey (or just sleeping) - no give title_i_want
else
#> 1B.1 - set current wid to target TWID
TWID = get_current_wid
#> 1B.2 - get title_i_want (with kdialog)
#> 1B.2.1 - default to current title
with_current_title TWID do |current_title|
# v :current_title #db
default_title = current_title
sublime_match = /
(?<beginning>.*?) # beginning might be...
# path
# untitled, find results, other useless junk
# ? dired
(?<dirty>\s•)? # dirty?
(?:\s\(\.?(?<projname>[^()]*)\))? # project name, preceded by "." (i name them that way), and in rkaks (sublime does that)
# or, sans dot, it's the dir, if the window was opened as a dir
(?<issub>\s-\sSublime\sText\s2\s\(UNREGISTERED\)) # garbage at the end that marks it as a sublime window
/x =~ current_title
#if it's a sublime window...
if sublime_match
dummy = beginning.split("/")
if dummy.length > 1
taildir = dummy[-2]
end
/? (?<direddir>.*)/ =~ beginning
default_title =
if projname ; projname
elsif taildir ; taildir
elsif direddir ; direddir
else ; beginning
end
end
if opts[:auto]
title_i_want = default_title
else
title_i_want = `kdialog --title "entitled" --inputbox "type the title you want and hit enter.\nto stop renaming,\njust enter nothing and hit esc" '#{default_title}'`.chomp
end
break
end
end
# v :terminal_wid #db
# v :TWID #db
# v :ARGV #db
# v :title_i_want #db
def set_title wid, title
`xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME "#{title}" -id #{wid}`
`xprop -f _NET_WM_ICON_NAME 8u -set _NET_WM_ICON_NAME "#{title}" -id #{wid}`
end
#> 2 - apply title to TWID
#> 2.1 - allow de-naming
#> 2.2 - allow renaming
# this bit is needed for a kludge that allows window renaming
has_renamed_before = false
interrupt_message = "WAIT WAIT I WANT A TURN BLOO BLOO BLEE BLUH BLOO" # hopefully i never want to actually use that as a title xD
`xprop -f _NET_WM_NAME 8u -set _NET_WM_NAME '#{interrupt_message}' -id #{TWID}`
with_current_title TWID do |current_title|
# if title_i_want is an empty string, exit
if title_i_want.empty?
# p 1 #db
set_title TWID, "WINDOW WILL START RENAMING ITSELF AS NORMAL"
exit
# if the current title is the interrupt message
# AND
# this script has renamed the window at least once before
# then we wanna let the new name take over
elsif current_title == interrupt_message and has_renamed_before
# p 2 #db
exit
# otherwise just change the title to what i want
elsif current_title != title_i_want
# p 3 #db
set_title TWID, title_i_want
has_renamed_before = true
end
end
답변
찾고있는 것은 창 태그 기능 과 같은 소리 입니다. 나는 KDE가 이것을 지원 하지 않을 것이라고 의심한다 ( XMonad 또는 DWM 등).
이 생산성 향상을 달성하기 위해 따라서 하나의 가능성은하는 것 무역 kwin
XMonad에 대한에 와 태깅을 수행하는 구성 XMonad . 두 번째 링크에 설명 된 XMonad 태깅 메커니즘은 키 조합을 바인딩하여 포커스 된 창에 태그를 지정할 수있는 프롬프트를 여는 것입니다. (XMonad의 설정은 실제로 Haskell 프로그램이므로 #xmonad에 도움을 요청하는 것을 망설이지 마십시오.
편집 : 모든 사람에게 적어도 한 번은 타일링 WM을 시도하도록 권유하지만 XMonad는 일반적으로 타일링 WM이라고하지만 “단순 부동 플로트”모드가 있음을 지적하는 것을 잊었습니다. 태그 지정 및 비 타일링 레이아웃을 지원하는 다른 WM이 있지만 KDE와의 상호 운용성에 대해서는 잘 모르겠습니다.
답변
창 제목을 쓰기 금지로 설정하는 방법이 없기 때문에 많은 프로그램이 이미 발견 한대로 다른 작업에서 제목을 재설정하기 때문에 해당 문제에 대한 해결책은 없습니다.
그러나 KDE와 그놈 사람들에게 좋은 제안 일 것입니다. 😉
답변
나는 똑같은 것을 찾고 있었고 같은 이유로. 이 70 줄 스크립트로 이것에 너무 많은 시간을 보냈습니다.
어떻게 작동합니까?
- 스크립트를 시작
- 제목을 설정하려는 창을 클릭하십시오
- 원하는 제목을 입력하십시오
그런 다음 백그라운드에서 루프를 시작하고 3 초마다 확인한 다음 제목이 변경되면 설정합니다.
경고 : 동일한 창에서 두 번 실행하지 마십시오. 스크립트가 완벽하지 않습니다.
스크립트 이름 예 :sticky-title
#!/bin/bash
# stop all instance of this script if "killall" provided as first argument
if [ "$1" == "killall" ]; then
scriptname=$(basename "$0")
pattern="[0-9]* /bin/bash .*$scriptname$"
pids=$(ps ax -o pid,cmd | grep -P "$pattern" | sed 's/^ *//;s/ *$//' | grep -Pv ' grep|killall$' | cut -d" " -f1)
if [ "$pids" != "" ]; then
kill -TERM $pids
echo "$(echo '$pids' | wc -l) instances stopped"
else
echo "None found to stop"
fi
exit 0
fi
# ask for window
echo -en "\nClick the window you want to set its title "
id=$(printf %i $(xwininfo | grep 'Window id' | cut -d" " -f4))
# fail if no window id
if [ "$id" == "" ]; then
echo 'Error: Window id not found'
exit 1
else
echo "- Got it"
fi
# ask for title
read -e -p "Enter target title: " title
# fail if no title
if [ "$title" == "" ]; then
echo "Error: No title to set"
exit 1
fi
# define loop as a function, so we can run it in background
windowByIdSetStickyTitle() {
local id title curr_title
id="$1"
title="$2"
while true; do
# get current title
curr_title="$(xdotool getwindowname $id 2>/dev/null)"
# exit if we can't find window anymore
if [ $? -ne 0 ]; then
echo "Window id does not exist anymore"
break
fi
# update title if changed
if [ "$curr_title" != "$title" ]; then
xdotool set_window --name "$title" $id
fi
# needed else you will eat up a significant amount of cpu
sleep 3
done
}
# infinite loop
windowByIdSetStickyTitle $id "$title" &
# done
echo "Sticky title set"
exit 0