Created
November 17, 2015 21:28
-
-
Save cabrinha/29b11e13e97c2afc86cd to your computer and use it in GitHub Desktop.
I think I'm doing the time part ... wrong.
This file contains hidden or 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
| -- Trying to make a status bar | |
| -- Internaught 11/11/15 | |
| -- I guess this draws a border? | |
| -- local boxBorder = 2 | |
| -- create some empty tables for our objects | |
| local bars = {} | |
| local iTunesBoxes = {} | |
| local iTunesTimers = {} | |
| -- grab the data, format the data | |
| function updateiTunesBoxes() | |
| local artist = hs.itunes.getCurrentArtist() | |
| local album = hs.itunes.getCurrentAlbum() | |
| local track = hs.itunes.getCurrentTrack() | |
| local result = string.format("%s - %s", artist, track) | |
| for _,iTunesBox in ipairs(iTunesBoxes) do | |
| iTunesBox:setText(result) | |
| end | |
| end | |
| -- Lets draw the bar, on as many screens as we have, across the top | |
| function drawTheBox() | |
| for _,screen in ipairs(hs.screen.allScreens()) do | |
| local frame = screen:frame() | |
| local box = hs.drawing.rectangle(hs.geometry.rect(frame.x, frame.y, frame.w, 25)) | |
| -- set the color and position of the panel | |
| box:setFillColor({["red"]=0.1,["blue"]=0.1,["green"]=0.1,["alpha"]=1}):setFill(true):show() | |
| table.insert(bars, box) | |
| -- Create the iTunes box | |
| local text = hs.drawing.text(hs.geometry.rect(frame.x + 2, frame.y + 2, frame.w - 2, 20), "") | |
| table.insert(iTunesBoxes, text) | |
| -- Set the text color | |
| text:setTextColor({["red"]=1,["blue"]=1,["green"]=1,["alpha"]=1}) | |
| -- Set the font size and font type | |
| text:setTextSize(14) | |
| text:setTextFont('Tamzen7x14') | |
| -- Tuck it in, under notifications, under the "real" menubar | |
| box:setLevel(hs.drawing.windowLevels["floating"]) | |
| text:setLevel(hs.drawing.windowLevels["floating"]) | |
| -- Show it off | |
| text:show() | |
| function drawTheTime() | |
| local timeClock = os.date("%a %b %d %I:%M:%S") | |
| local timeClockText = hs.drawing.text(hs.geometry.rect(frame.x + 3215, frame.y + 2, frame.w - 2, 20), timeClock) | |
| timeClockText:setTextColor({["red"]=1,["blue"]=1,["green"]=1,["alpha"]=1}) | |
| timeClockText:setTextSize(14) | |
| timeClockText:setTextFont('Tamzen7x14') | |
| timeClockText:setLevel(hs.drawing.windowLevels["floating"]) | |
| timeClockText:show() | |
| end | |
| local timeClocker = hs.timer.doEvery(1, drawTheTime):start() | |
| end | |
| end | |
| -- Refresh the iTunes data every 3 seconds | |
| local iTunesTimer = hs.timer.doEvery(3, updateiTunesBoxes):start() | |
| local boxDrawer = hs.timer.doEvery(600, drawTheBox):start() | |
| updateiTunesBoxes() | |
| drawTheBox() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment