Skip to content

Instantly share code, notes, and snippets.

/a.go Secret

Created June 26, 2017 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d0973381fe840896c678b95097fa94fd to your computer and use it in GitHub Desktop.
Save anonymous/d0973381fe840896c678b95097fa94fd to your computer and use it in GitHub Desktop.
func main() {
var wg sync.WaitGroup
currentWindow, e := exec.Command("xdotool", "getactivewindow").Output()
if e != nil {
fmt.Println(e)
}
cmd := exec.Command("xev", "-id", string(currentWindow), "-event", "property")
if e != nil {
fmt.Println(e)
}
stdout, e := cmd.StdoutPipe()
cmd.Start()
wg.Add(1)
go func() {
for {
_, err := stdout.Read(make([]byte, 1))
if err == nil {
cols, _ := exec.Command("tput", "cols").Output()
rows, _ := exec.Command("tput", "lines").Output()
fmt.Println("columns: ", string(cols))
fmt.Println("rows: ", string(rows))
} else {
wg.Done()
}
}
}()
wg.Wait()
fmt.Println("dadasdasd")
}
/*
*/
var spawn = require('child_process').spawn
var spawnSync = require('child_process').spawnSync
const currentWindowID = spawnSync('xdotool', ['getactivewindow']).stdout.toString()
var xevent = spawn('xev', ['-id', currentWindowID.substr(0, currentWindowID.length - 1), '-event', 'property'])
/* ^--- remove the newline from the end of the currentWindowID */
xevent.stdout.on('data', function (data) {
console.log('cols', spawnSync('tput', ['cols']).stdout.toString())
console.log('lines', spawnSync('tput', ['lines']).stdout.toString())
})
console.log('something else')
/*
*/
function termSize() {
xev -id $(xdotool getactivewindow) -event property | while read line
do
tput cols
tput lines
done
}
termSize &
echo "something else"
#
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
##
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment