Last active
January 18, 2021 22:48
-
-
Save sanjarcode/74f6d66750caacf59e3dd62fe83ae15e to your computer and use it in GitHub Desktop.
gnome-shell-extensions snippets
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 for debugging gnome-shell-extensions by printing text to the desktop | |
function displayLog(textP="Hello, World!", fontSize=36) { | |
// get dependencies | |
const Main = imports.ui.main; | |
const Tweener = imports.ui.tweener; | |
// set style | |
textBox = new St.Label({style: ` | |
font-size: ${fontSize}px; | |
font-weight: bold; | |
color: #ffffff; | |
background-color: rgba(10,10,10,0.7); | |
border-radius: 5px; | |
padding: .5em; | |
opacity: 255; | |
`, text: textP.toString().match(new RegExp('.{1,' + Math.floor(Main.layoutManager.primaryMonitor.width / fontSize) + '}', 'g')).join("\n") | |
// divide the text into smaller lines for displaying | |
}); | |
// inject textBox to display | |
Main.uiGroup.add_actor(textBox); | |
// text disappears after 2 seconds | |
Tweener.addTween(textBox, | |
{ opacity: 0, | |
time: 2, | |
transition: 'easeOutQuad', | |
onComplete: function _hideHello() { | |
Main.uiGroup.remove_actor(textBox); | |
textBox = null; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment