KDE में एक मनमानी खिड़की के लिए विंडो शीर्षक को ओवरराइड करें और एक कस्टम विंडो शीर्षक सेट करें


14

यहां केडीई का उपयोग करना, लेकिन एक समाधान हो सकता है जो अन्य डेस्कटॉप वातावरण के साथ भी काम करता है। मैं अक्सर कई खिड़कियों के साथ काम कर रहा हूं। अधिकांश विंडो में कई टैब होते हैं (जैसे कई टैब के साथ डॉल्फिन विंडो, या फ़ायरफ़ॉक्स, कॉनसोल, आदि)। विंडो का शीर्षक मेरे वर्तमान टैब के आधार पर बदल जाएगा (जो कि अधिकांश भाग के लिए सबसे अधिक समय के लिए सहायक होता है), लेकिन जब कई खिड़कियों के साथ काम कर रहा हूं तो मैं उन्हें थोड़ा व्यवस्थित करना चाहता हूं और मैन्युअल रूप से विंडो को फिर से नाम देने में सक्षम हो सकता हूं ओवरराइडिंग, खिड़की का शीर्षक जो कि एप्लिकेशन देता है । मैं एक फ़ायरफ़ॉक्स विंडो "रिसर्च" और अन्य फ़ायरफ़ॉक्स विंडो "डॉक्यूमेंटेशन" का नाम दे सकता हूं, जो कि मैं उन खिड़कियों के बीच आसानी से भेद करने में सक्षम हो सकता हूं, जिनके अनुसार मैंने अलग-अलग टैब को व्यवस्थित और समूहित किया है।

आदर्श रूप से मैं एक विंडो टाइटल बार पर क्लिक कर सकता हूं और आसानी से इसे एक कस्टम नाम दे सकता हूं, लेकिन मैं एक ऐसे समाधान के लिए व्यवस्थित हो जाऊंगा, जो तब तक थोड़ा अधिक बोझिल हो जब तक यह काम करता है।

मैंने कोशिश की है, wmctrl -r :SELECT: -T "Research"लेकिन यह केवल अस्थायी रूप से काम करता है (शीर्षक को तब बदला जाता है जब अनुप्रयोग इसे बदलता है, उदाहरण के लिए टैब स्विच करते समय)।


नेटिव KDE ऐप्स में एक --captionकमांड-लाइन विकल्प होता है जो आपको विंडो शीर्षक सेट करने की सुविधा देता है, लेकिन मुझे नहीं लगता कि आप जो खोज रहे हैं वह काफी है।
डेविड ज़ेड

@ सीनमेनडेन अरे, क्या आपको अभी भी इसकी आवश्यकता है? यदि आप करते हैं, तो मुझे यह जानकर अच्छा लगेगा कि क्या आप मेरे लिए अपनी स्क्रिप्ट प्राप्त कर सकते हैं। ^^;
ओवेन_आर

धन्यवाद @Owen_R आपकी स्क्रिप्ट ने काम किया, और मैंने GitHub पर इसके लिए एक रेपो जोड़ा ।
सीन

@ सीनमेडेन हा, मैं किसी और को सुनकर खुश हूं कि आखिरकार मेरे जवाब से कुछ फायदा हुआ! हालाँकि मजेदार बात यह है कि मैं खुद उस मछली की स्क्रिप्ट का उपयोग नहीं करता हूँ; मैंने इसे थोड़ी देर पहले रूबी में लिखा था। मैं वास्तविक रूप से जल्द ही अपने आप को कभी भी जीथब पर डालने के लिए चारों ओर जाने वाला हूं, हालांकि, इसलिए मैंने इसे अपने जवाब के अंत में संपादित किया है यदि आप इसे चाहते हैं।
ओवेन_आर

जवाबों:


4

मुझे भी यही समस्या थी।

इसलिए मैंने एक शेल स्क्रिप्ट लिखी जिसे मैं हॉटकी से बांधता हूं।

जब मैं हॉटकी मारता हूं, तो उसे वर्तमान में सक्रिय विंडो की विंडो आईडी मिलती है (जिस पर फोकस होता है)।

फिर यह आपको एक पॉपअप डायलॉग देता है, जहां आप उस शीर्षक को दर्ज करते हैं जिसे आप चाहते हैं कि विंडो हो।

फिर हर बार जब वह खिड़की अपना नाम बदलती है, तो वह इसे वापस उस शीर्षक में बदल देती है जिसे आप चाहते हैं।

स्क्रिप्ट का उपयोग करने के लिए, आपको आवश्यकता है:

  • fishखोल
    (मैं नहीं बल्कि पार्टी cuz बैश से मछली में लिखा था मुझे सिर में दर्द देता है)

  • kdialog

  • किसी तरह स्क्रिप्ट को हॉटकी से बाँधने के लिए
    (मैं उपयोग करता हूँ xbindkeys, क्यूज़ सभी को काम करने के लिए मुझे इसे जोड़ना था:

"[PATH TO SCRIPT]/[NAME OF SCRIPT]" Mod4 + t

(वह है, विंडो की + t)
मेरे लिए /home/o1/.xbindkeysrc)

इस दोस्त के लिए धन्यवाद , जिसने मुझे जादू xprop सामान की जानकारी दी।

(जैसे, एक साल पहले, और फिर मैं आज स्क्रिप्ट लिखने के लिए आसपास नहीं था। xD)

पुनश्च यदि कोई नौसिखिया यह उत्तर पाता है और यह नहीं जानता कि इसका उपयोग कैसे किया जाए, तो बस मुझसे पूछें और मैं आपको इसके माध्यम से चलता हूं। ^^

संपादित करें: मैं यह तो अद्यतन है कि आप स्विच के साथ कमांड लाइन से उपयोग कर सकते हैं -tके लिए title_i_wantऔर -wके लिए 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

हाँ यह मेरे लिए काम किया!
सीन

इस स्क्रिप्ट को GitHub पर यहाँ खोजें : github.com/seanmadsen/kustom-window-title
सीन

रूबी स्क्रिप्ट कुबंटु 16.04 पर काम नहीं करती है? मुझे पॉप-अप विंडो मिलती है, लेकिन विंडो का शीर्षक नहीं बदलता है। मछली स्क्रिप्ट महान काम करता है, हालांकि!
सुपरनैचुरल

2

आप एक विंडो टैगिंग सुविधा जैसी ध्वनियों की तलाश कर रहे हैं । मुझे संदेह है कि केडीई के पास इसके लिए समर्थन है, अन्य डब्ल्यूएम (जैसे एक्सएमनाड या डीडब्ल्यूएम आदि) करते हैं।

इस उत्पादकता को बढ़ावा देने को प्राप्त करने के इस प्रकार एक संभावना के लिए होगा व्यापार kwinXMonad के लिए में और कॉन्फ़िगर XMonad टैगिंग करने के लिए । दूसरे लिंक में वर्णित एक्समोनॉड टैगिंग तंत्र एक प्रमुख संयोजन को एक शीघ्र खोलने के लिए बाध्य करेगा कि आप केंद्रित विंडो को टैग करते हैं। (एक्समोनाड का विन्यास वास्तव में हस्केल-प्रोग्राम है, इसलिए #xmonad में मदद मांगने में संकोच न करें।

संपादित करें: जबकि मैं सभी को सलाह दूंगा कि वे कम से कम एक बार WM की कोशिश करें, मैं यह बताना भूल गया कि जब XMonad को आम तौर पर टाइलिंग WM के रूप में संदर्भित किया जाता है, तो एक "सरल फ्लोट" -मोड होता है। निश्चित रूप से अन्य WMs हैं जो टैगिंग और गैर-टाइलिंग लेआउट का समर्थन करते हैं, लेकिन मुझे केडीई के साथ उनकी अंतर के बारे में जानकारी नहीं है।


1

चूँकि प्रोटेक्ट लिखने के लिए विंडो टाइटल सेट करने का कोई तरीका नहीं है, इसलिए उस समस्या का कोई हल नहीं होगा, क्योंकि कई प्रोग्राम अलग-अलग क्रियाओं पर अपना टाइटल रीसेट कर देते हैं जैसा कि आप पहले ही खोज चुके हैं।

लेकिन शायद केडीई और सूक्ति लोगों के लिए एक अच्छा सुझाव ;-)


0

मैं एक ही चीज की तलाश कर रहा था और एक ही वजह से। इस पर बहुत अधिक समय बिताने के लिए, इस 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
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.