--- Log opened Thu Nov 21 00:00:44 2019 |
00:45 | <@sshine> | abudhabi, you could use GNU 'ls' and import your color scheme. that's what I typically did the last time I used FreeBSD. |
00:45 | <@sshine> | abudhabi, I think the package is 'gnuls' |
00:47 | < Yossarian> | 14:09:44 <&[R]> Blue light fucks up your ability to sleep --> Ideally, it should be near pitch black when one sleeps, messed with your rhythms |
00:48 | <&McMartin> | These are both true statements. |
00:48 | <&McMartin> | But if you go get water at night or something, blue light for many people sets off "oh, it must be morning, shut down the sleepiness" thing and hello insomnia |
00:48 | < Yossarian> | I try to tell people this IRL but my mother still insists on the television for bg noise, which I suppose is alright. |
00:49 | <&McMartin> | I use a laptop, but I angle it away from me. |
00:49 | <&McMartin> | And of course, there are the blunt instruments of sleep blindfolds or being all the way under the blanket. |
00:50 | <&McMartin> | I'd say "I don't know why this is #code" but coding is why I need the amber-tinge modes for displays |
00:50 | < Yossarian> | Lots of LCD TVs have a sleep mode that reduces brightness and then might have the option of a timer to turn it off completely. |
00:52 | <&McMartin> | Right, but, like, I'm playing soothing music, and then letting the screensaver sleep it :) |
00:52 | < Yossarian> | Lots of coding places have CCFL lighting and gives me a damned headache after several hours. Also, LCD backlight in a lot of laptops at maximum is a bit bright, damn, man. |
00:53 | <&McMartin> | There's a lot I don't like about the temp office we have right now, but "mostly lit by skylights during the day" is not one of them |
01:19 | | celmin|away is now known as celticminstrel |
01:28 | | Kindamoody is now known as Kindamoody[zZz] |
01:57 | <@sshine> | Yossarian, I've met people (mostly women) who sleep best with a tv turned on. I'm pretty sure it lowers quality of sleep, but I suppose it's better than not sleeping. :-) |
01:58 | <@celticminstrel> | Probably depends on the channel… |
02:08 | < Yossarian> | women are weird but I like 'em |
02:21 | | Degi [Degi@Nightstar-tqvuqj.dyn.telefonica.de] has quit [Ping timeout: 121 seconds] |
02:23 | | Degi [Degi@Nightstar-35s8vd.dyn.telefonica.de] has joined #code |
02:46 | <@celticminstrel> | . |
03:03 | <@Alek> | my parents both do it a lot. |
03:03 | <@Alek> | I think it's mainly for the background sound, tbh. |
03:04 | <@Alek> | If I could hear, I wouldn't mind some background chill music to sleep to. |
03:05 | <@Alek> | well. I can hear, but only with my processor on, and I can't really keep it on while sleeping because a) it gets uncomfortable and in the way, and b) it uses up battery. |
03:41 | <@sshine> | lately I've been sleeping with the lights on. |
03:52 | <@Alek> | that I'm not a fan of, although I usually can. |
05:06 | | Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has joined #code |
05:06 | | mode/#code [+qo Vorntastic Vorntastic] by ChanServ |
05:19 | | himi-cat [sjjf@Nightstar-1drtbs.anu.edu.au] has quit [Operation timed out] |
05:26 | | celticminstrel [celticminst@Nightstar-2kik29.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
07:57 | | himi-cat [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code |
09:05 | | Kindamoody[zZz] is now known as Kindamoody |
10:30 | <@sshine> | the joke is, we're doing this huge amount of work to make the company website responsive, but in the process, a bunch of pages are being re-designed so all relevant content disappears from the first screens. |
10:42 | <@sshine> | but a nice consequence is that I get to put nice breakpoints on everything. :-) |
10:56 | | Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has joined #code |
13:08 | | celticminstrel [celticminst@Nightstar-2kik29.dsl.bell.ca] has joined #code |
13:08 | | mode/#code [+o celticminstrel] by ChanServ |
13:31 | | celticminstrel is now known as celmin|away |
13:57 | | VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has quit [Connection closed] |
13:58 | | VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code |
13:58 | | mode/#code [+ao VirusJTG VirusJTG] by ChanServ |
15:04 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code |
15:04 | | mode/#code [+qo Vornicus Vornicus] by ChanServ |
19:45 | | Saraah [Saraah@Nightstar-cq1.fba.47.202.IP] has joined #code |
19:46 | | Saraah [Saraah@Nightstar-cq1.fba.47.202.IP] has quit [[NS] Quit: ] |
20:37 | | Vorntastic [uid293981@Nightstar-6br85t.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity] |
20:53 | < Yossarian> | Can a bash alias be seperated by \ ? |
20:53 | < Yossarian> | like can one do a little script in an alias? |
20:55 | | himi-cat [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds] |
21:03 | <&ToxicFrog> | Yossarian: Yes. You can also separate commands in the alias with ; as normal. That said, if you're doing anything lengthy or complicated you should use a function instead. |
21:04 | < Yossarian> | huh? |
21:04 | < Yossarian> | what am i doin rong syntactically here I wonder? |
21:09 | < Yossarian> | I can copy-paste two lines on this network, right? |
21:09 | <~Vornicus> | yeah |
21:09 | <~Vornicus> | more than like ...four and you should pastebin obv |
21:09 | < Yossarian> | oh |
21:09 | < Yossarian> | I dunno, it didn't like the first line at first here: |
21:10 | < Yossarian> | cur_speed=$(cat /proc/acpi/ibm/fan | grep -i "level:" | awk '{print $2}'); |
21:10 | < Yossarian> | echo cur_speed; |
21:10 | < Yossarian> | the parens were red |
21:25 | <&ToxicFrog> | That looks correct to me (nit: you probably want to get in the habit of enclosing the whole $(...) in "", although I don't think it matters here specifically) |
21:25 | <&ToxicFrog> | You want `echo $cur_speed` afterwards, though |
21:25 | < Yossarian> | yeah my vim copying skills are whack |
21:26 | < Yossarian> | its " (buffer) and then y for yank, yeah? |
21:26 | < Yossarian> | + or * being primary or clipboard |
21:27 | <&McMartin> | That's X11's fault, not Vim's >_< |
21:28 | <&ToxicFrog> | No idea, I don't use vim |
21:29 | <&ToxicFrog> | Are you sure the red was "error" and not "bracket matching"? |
21:30 | < Yossarian> | not sure but fixed |
21:37 | < Yossarian> | multi-line command is giving me some trouble, syntax though |
21:38 | < Yossarian> | oh, |
21:38 | < Yossarian> | $func needs to be surrounded by double quotes sometimes to protect it |
21:46 | <&ToxicFrog> | ...yes. |
21:47 | < Yossarian> | I still haven't slept yet, work murdered me |
21:50 | < Yossarian> | eek |
22:00 | < Yossarian> | https://termbin.com/kv0o |
22:00 | < Yossarian> | little confused on lines 25 and 26 |
22:02 | <&ToxicFrog> | Ok, first of all, the whole if block can be replaced with: |
22:02 | < Yossarian> | case? |
22:02 | <&ToxicFrog> | if [[ "$cur_speed" == "auto" ]]; then |
22:03 | <&ToxicFrog> | swap_speed="full-speed"; |
22:03 | <&ToxicFrog> | fi |
22:03 | < Yossarian> | or a short logical operator |
22:03 | < Yossarian> | oh |
22:03 | <&ToxicFrog> | The other branches are redundant (swap_speed is already set to auto during initialization) and you should always use [[]] instead of [] if you're targeting bash/zsh |
22:03 | <&ToxicFrog> | I'm not sure what you're trying to do with toggle_notify; or rather, I think I know, but I don't know why you're trying to do it that way. |
22:04 | < Yossarian> | but $cur_speed might be "full-speed" |
22:04 | < Yossarian> | I want to toggle between the two |
22:04 | < Yossarian> | but you're saying |
22:04 | < Yossarian> | the redundancy I built in |
22:04 | <&ToxicFrog> | Yeah, in which case the test will fail, the if block will be skipped and swap_speed will remain set to "auto" |
22:04 | < Yossarian> | or rather the default |
22:04 | <&ToxicFrog> | Because you initialized it to "auto" two lines ago |
22:04 | < Yossarian> | that's why I commented # redundant code ahead? |
22:05 | <&ToxicFrog> | Yes. That branch and the one before it were redundant. |
22:06 | <&ToxicFrog> | if [[ $cur_speed == full-speed ]]; then swap_speed="auto"; is a no-op whether it passes or fails because swap_speed was already auto. |
22:06 | < Yossarian> | sorry I went ahead and wrote and then went backwards, it was dumb |
22:06 | <&ToxicFrog> | As for lines 25-26 -- |
22:06 | < Yossarian> | is ` bad form for zsh? |
22:06 | <&ToxicFrog> | It's bad form for both bash and zsh. Never use it in either shell. |
22:07 | <&ToxicFrog> | `...` is an older (and deprecated) form of $(...), so what that line does is run echo ... | sudo tee ... && notify-send, then assign whatever tee && notify-send output to toggle_notify |
22:07 | < Yossarian> | and should notify-send be in the same function variable but or with its own $() ? or... |
22:07 | <&ToxicFrog> | Then you just '$toggle_notify', i.e. "take whatever that command output and run that as a command" |
22:07 | <&ToxicFrog> | What do you mean by "function variable" here? |
22:08 | <&ToxicFrog> | There are no functions in your script. |
22:08 | < Yossarian> | eh you define a variable with command replacement |
22:08 | < Yossarian> | that's what I mean |
22:08 | <&ToxicFrog> | Why are you doing that, though? Why are you trying to run the output of that command as a command itself? |
22:09 | < Yossarian> | I want to do the toggle and then give a notification, I've been up since 11PM yesterday, I'm sorry my man |
22:09 | <&ToxicFrog> | So...do the toggle, and then call notify-send. There's no need to use command substitution here at all. |
22:10 | <&ToxicFrog> | echo "level $swap_speed" | sudo tee /proc/acpi/ibm/fan \ |
22:10 | <&ToxicFrog> | && notify-send "Changed fan speed to $swap_speed." |
22:10 | <&ToxicFrog> | You don |
22:11 | < Yossarian> | to do the toggle, you have to 'echo "level auto" | sudo tee /proc/acpi/ibm/fan |
22:11 | < Yossarian> | to change the fan speed |
22:11 | <&ToxicFrog> | You don't even need the && if you `set -e` at the top of the script (which makes it exit automatically if a command fails) |
22:11 | <&ToxicFrog> | Yes. That's the code I just gave you does. |
22:11 | <&ToxicFrog> | You don't need to store the output of the command in a variable and then interpret that output (??????) in order for the original command to take effect. |
22:13 | < Yossarian> | i don't know, i was trying to make it into a function via command sub |
22:13 | <&ToxicFrog> | That is not how you make functions. |
22:13 | <&ToxicFrog> | When you write foo=`bar` or foo=$(bar), what happens is: |
22:13 | <&ToxicFrog> | - bar is executed immediately |
22:14 | <&ToxicFrog> | - whatever output bar would normally have sent to the terminal is instead stored in $foo |
22:14 | <&ToxicFrog> | When you write this at the start of the script: |
22:14 | <&ToxicFrog> | cur_speed="$(cat /proc/acpi/ibm/fan | grep -i "level:" | awk '{print $2}')" |
22:15 | <&ToxicFrog> | cur_speed is not made into a function that gets the current fan speed; that cat|grep|awk pipeline is executed as soon as that line is read and the output of awk is stored in $cur_speed. No matter how many times you refer to $cur_speed, it won't re-execute that command, just returned the saved output. |
22:16 | <&ToxicFrog> | Basically, $(...) in bash is a function call, not a function definition. |
22:16 | < Yossarian> | I thought something to that affect, which is why I tried to make toggle_notify and moved it down further |
22:16 | < Yossarian> | Ah. |
22:16 | <&ToxicFrog> | Why do you need to make toggle_notify at all rather than just running echo/tee/notify-send directly? |
22:16 | <&ToxicFrog> | It doesn't really need to be its own function. |
22:16 | < Yossarian> | I don't know, I've been up a long time. I don't have time to write code any more |
22:17 | < Yossarian> | I store trucks with packages |
22:17 | <&ToxicFrog> | That said, if you did want it to be a function, you'd define it as one using the function keyword: |
22:17 | <&ToxicFrog> | function toggle-notify { |
22:17 | <&ToxicFrog> | echo "level $1" | sudo tee /proc/acpi/ibm/fan || return 1 |
22:18 | <&ToxicFrog> | notify-send "Changed fan speed to $1" |
22:18 | < Yossarian> | Thanks for taking the time to help a moron. |
22:18 | <&ToxicFrog> | } |
22:18 | <&ToxicFrog> | toggle-notify "$swap_speed" |
22:18 | <&ToxicFrog> | Not a moron, but if you're unfamiliar with bash -- and it looks like you are -- it might be better to revisit this script when you're better rested :) |
22:18 | <&ToxicFrog> | It's a language with a lot of weird angles and traps for the unwary. |
22:24 | <&ToxicFrog> | For reference, here's probably how I'd write it: https://gist.github.com/ToxicFrog/f03f4c4387050ded7c30e72dbbe8b7fc |
22:24 | <&ToxicFrog> | (with some hopefully helpful annotations) |
22:29 | < Yossarian> | # Also needs fan_control=1 in thinkpad_acpi kmod options. |
22:29 | < Yossarian> | Forgot about that. |
22:30 | <&[R]> | `grep -i "level:" | awk '{print $2}'` == awk '/level:/i {print $2}' |
22:35 | < Yossarian> | I'm so tired |
22:36 | <&[R]> | Then sleep |
22:36 | <&[R]> | You have to get up in 7 hours anyways, right? |
22:37 | <&ToxicFrog> | ^ |
22:38 | < Yossarian> | I guess |
22:39 | < Yossarian> | I have zero leisure time with public transport |
22:39 | <&McMartin> | Speaking of traps though |
22:39 | <&McMartin> | I have recently been apprised of the existence of ShellCheck |
22:40 | <&[R]> | <Yossarian> I have zero leisure time with public transport <-- PT /is/ liesure time though |
22:40 | <&McMartin> | It didn't answer the questions I had for it, but that doesn't make it any less solid a tool for what it's intended to be |
22:40 | < Yossarian> | it isn't intellectually productive to my persuits |
22:40 | < Yossarian> | pursuits |
22:42 | | * [R] did a ton of coding when he rode the bus to IBM |
22:42 | <&[R]> | Also reading |
22:42 | <&McMartin> | I can read but not write on transit |
22:43 | < Yossarian> | the rides are short in and of themselves |
22:44 | < Yossarian> | and i can't take my laptop in the facility or at least if I did I would have no place to put it |
22:44 | <~Vornicus> | with the amount of sitting around I do at work I wish I could program there |
22:46 | < Yossarian> | during work hours it is non stop moving |
22:46 | < Yossarian> | i almost fell and cracked my head open in this other department |
22:46 | < Yossarian> | from up high |
23:11 | | himi-cat [sjjf@Nightstar-1drtbs.anu.edu.au] has joined #code |
23:18 | | Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds] |
23:46 | <@Alek> | apparently there are code editors for smartphones now. |
23:46 | <@Alek> | I know there's a number of learn-to-code apps anyway, I've got a couple I'm working on. |
23:47 | <@Alek> | sure it's not as easy as a keyboard, but it's something. |
23:47 | <&McMartin> | ISTR there have been some pretty solid communities in wacky niche languages running on tablets. |
23:47 | <&McMartin> | Ofc, tablets *have* keyboards |
23:49 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection closed] |
--- Log closed Fri Nov 22 00:00:45 2019 |