Giter Club home page Giter Club logo

Comments (2)

eskalVAR avatar eskalVAR commented on July 18, 2024

Hello, I used to use unbuffer xtitle -s -t 50 where 50 is the length of the window.

This works well but sometimes de-syncs requiring a quick i3 reload. I now run polybar in the background to stdout as the window command in i3blocks polybar -q --stdout | grep -o -P '(?<=%{l}).*(?=%{PR})' however still the face issue just left often. Let me know how you get on!

from i3blocks.

mrgreen3 avatar mrgreen3 commented on July 18, 2024

Sorry for the late reply ;-)

This is more viable script and does work.

#!/bin/bash
# A simple blocket that prints window title in center of panel.
# Very much dependant on guessing the total length?

window_title=$(xdotool getactivewindow getwindowname)

# Estimation of characters in the block (modify this as per your estimate)
total_length=200 

length=${#window_title}
padding_length=$(( total_length - length ))

# Generate the padding string with underscores
padding=$(printf ' %.0s' $(seq 1 $padding_length))

# Print the window title followed by the padding string
echo  "$window_title $padding"

This is a bit of trial and error as finding the 'center' of screen depends on quite a few variables and calculations.

Based total_length by pure guess work.

from i3blocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.