cleanup
This commit is contained in:
parent
70833be3fa
commit
f672f64aeb
11
cbar.c
11
cbar.c
@ -25,6 +25,7 @@ static char cpu_avg_speed[24];
|
|||||||
static char volume[24];
|
static char volume[24];
|
||||||
|
|
||||||
void update_volume() {
|
void update_volume() {
|
||||||
|
/* TODO: This should use sndiod and not the raw device */
|
||||||
const wchar_t ico_vol = 0xF028; //
|
const wchar_t ico_vol = 0xF028; //
|
||||||
// Open the audio control device
|
// Open the audio control device
|
||||||
int fd = open("/dev/audioctl0", O_RDONLY);
|
int fd = open("/dev/audioctl0", O_RDONLY);
|
||||||
@ -76,7 +77,7 @@ void update_cpu_base_speed() {
|
|||||||
int temp;
|
int temp;
|
||||||
size_t templen = sizeof(temp);
|
size_t templen = sizeof(temp);
|
||||||
|
|
||||||
int mib[5] = { CTL_HW, HW_CPUSPEED }; // Lenovo x1g10,13
|
int mib[5] = { CTL_HW, HW_CPUSPEED };
|
||||||
|
|
||||||
if (sysctl(mib, 2, &temp, &templen, NULL, 0) == -1)
|
if (sysctl(mib, 2, &temp, &templen, NULL, 0) == -1)
|
||||||
snprintf(cpu_base_speed,sizeof(cpu_base_speed), "%lc N/A", ico_freq);
|
snprintf(cpu_base_speed,sizeof(cpu_base_speed), "%lc N/A", ico_freq);
|
||||||
@ -93,7 +94,7 @@ void update_cpu_avg_speed() {
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 24; i++) {
|
for (i = 0; i < 24; i++) {
|
||||||
|
|
||||||
int mib[5] = { CTL_HW, HW_SENSORS, 0, SENSOR_FREQ, 0 }; // Lenovo x1g10,x13
|
int mib[5] = { CTL_HW, HW_SENSORS, 0, SENSOR_FREQ, 0 };
|
||||||
|
|
||||||
if (sysctl(mib, 5, &sensor, &templen, NULL, 0) != -1) {
|
if (sysctl(mib, 5, &sensor, &templen, NULL, 0) != -1) {
|
||||||
count++;
|
count++;
|
||||||
@ -113,7 +114,7 @@ void update_fan_speed() {
|
|||||||
// grab first sensor that provides SENSOR_FANRPM
|
// grab first sensor that provides SENSOR_FANRPM
|
||||||
if (fan_mib == -1) {
|
if (fan_mib == -1) {
|
||||||
for (fan_mib=0; fan_mib<20; fan_mib++) {
|
for (fan_mib=0; fan_mib<20; fan_mib++) {
|
||||||
int mib[5] = { CTL_HW, HW_SENSORS, fan_mib, SENSOR_FANRPM, 0 }; // acpitz0.temp0 (x13)
|
int mib[5] = { CTL_HW, HW_SENSORS, fan_mib, SENSOR_FANRPM, 0 };
|
||||||
if (sysctl(mib, 5, &sensor, &templen, NULL, 0) != -1)
|
if (sysctl(mib, 5, &sensor, &templen, NULL, 0) != -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -236,6 +237,7 @@ void update_battery() {
|
|||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "C");
|
setlocale(LC_CTYPE, "C");
|
||||||
setlocale(LC_ALL, "en_US.UTF-8");
|
setlocale(LC_ALL, "en_US.UTF-8");
|
||||||
|
|
||||||
@ -265,10 +267,9 @@ int main(int argc, const char *argv[])
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if(argc == 2) {
|
if(argc == 2)
|
||||||
if(strcmp("-1", argv[1]) >= 0)
|
if(strcmp("-1", argv[1]) >= 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
usleep(1000000);
|
usleep(1000000);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user