+gboolean determine_chassis_and_icon() {
+
+ char *hwproduct, *hwmodel, *hwvendor, *hwmachine;
+ size_t hwproduct_size, hwmodel_size, hwvendor_size, hwmachine_size;
+ int hwproduct_name[2], hwmodel_name[2], hwvendor_name[2], hwmachine_name[2];
+ unsigned int i;
+ gboolean UNSURE_CHASSIS_FLAG, UNSURE_ICON_FLAG;
+
+ hwproduct = hwmodel = hwvendor = hwmachine = NULL;
+ hwproduct_size = hwmodel_size = hwvendor_size = hwmachine_size = 0;
+ UNSURE_CHASSIS_FLAG = UNSURE_ICON_FLAG = FALSE;
+
+ hwproduct_name[0] = CTL_HW;
+ hwproduct_name[1] = HW_PRODUCT;
+
+ hwmodel_name[0] = CTL_HW;
+ hwmodel_name[1] = HW_MODEL;
+
+ hwvendor_name[0] = CTL_HW;
+ hwvendor_name[1] = HW_VENDOR;
+
+ hwmachine_name[0] = CTL_HW;
+ hwmachine_name[1] = HW_MACHINE;
+
+ /* pass NULL buffer to check size first, then pass hw to be filled according to freshly-set hw_size */
+ if(-1 == sysctl(hwproduct_name, 2, NULL, &hwproduct_size, NULL, 0) || -1 == sysctl(hwproduct_name, 2, hwproduct, &hwproduct_size, NULL, 0))
+ return FALSE;
+
+ if(-1 == sysctl(hwmodel_name, 2, NULL, &hwmodel_size, NULL, 0) || -1 == sysctl(hwmodel_name, 2, hwmodel, &hwmodel_size, NULL, 0))
+ return FALSE;
+
+ if(-1 == sysctl(hwvendor_name, 2, NULL, &hwvendor_size, NULL, 0) || -1 == sysctl(hwvendor_name, 2, hwvendor, &hwvendor_size, NULL, 0))
+ return FALSE;
+
+ if(-1 == sysctl(hwmachine_name, 2, NULL, &hwmachine_size, NULL, 0) || -1 == sysctl(hwmachine_name, 2, hwmachine, &hwmachine_size, NULL, 0))
+ return FALSE;
+
+ /* TODO: test for laptop, if not, dmidecode for desktop vs. server
+ * probably move this code to vm test func and set a global after running it early, once */
+
+ for(; i < G_N_ELEMENTS(chassis_indicator_table); i++) {
+ if(strcasestr(hwproduct, chassis_indicator_table[i].match_string)
+ || strcasestr(hwmodel, chassis_indicator_table[i].match_string)
+ || strcasestr(hwvendor, chassis_indicator_table[i].match_string)) {
+
+ if(!UNSURE_CHASSIS_FLAG && chassis_indicator_table[i].chassis) {
+
+ UNSURE_CHASSIS_FLAG = chassis_indicator_table[i].chassis_precedence;
+ CHASSIS = chassis_indicator_table[i].chassis;
+ }
+
+ if(!UNSURE_ICON_FLAG && chassis_indicator_table[i].icon) {
+
+ UNSURE_ICON_FLAG = chassis_indicator_table[i].icon_precedence;
+ ICON = chassis_indicator_table[i].icon;
+ }
+ }
+ }
+
+ if(up_native_is_laptop()) {
+
+ if(!CHASSIS)
+ CHASSIS = "laptop";
+ if(!ICON)
+ ICON = "input-touchpad"; /* TODO pull an icon package that actually has the icons we're looking for */
+
+ } else if(is_server(hwmachine)) {
+
+ if(!CHASSIS)
+ CHASSIS = "server";
+ if(!ICON)
+ ICON = "uninterruptible-power-supply";
+
+ } else if(!CHASSIS || !ICON) {
+
+ if(!CHASSIS)
+ CHASSIS = "desktop";
+ if(!ICON)
+ ICON = "computer";
+ }