-
-
Save anonymous/d0973381fe840896c678b95097fa94fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
/* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
/* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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