~mmach/netext73/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
#!/bin/bash
## Graficzny instalator kerneli e X t 7 3  - NeteXt'73
## przygotowanie kerneli e X t 7 3 - ext73@wp.pl
## przygotowanie skryptów optymalizacyjnych e X t 7 3
## autor skryptu NeteXt'73 - NetBit73 - netbit73@gmail.com
## Licencja: GPL v3: https://www.gnu.org/licenses/gpl.txt
#########################################################################################################################################################################


LATEST_VERSION=$(grep 'v[0-9]' /opt/NeteXt73/changelog | head -n 1 | cut -d 'v' -f 2)

#katalog dla configów
if [ ! -e /etc/netext73 ]; then
	mkdir /etc/netext73 -p
fi

jezyczek(){
#teksty w języku polskim
if [ -e /etc/netext73/jezyk ]; then
	if [ "$(cat /etc/netext73/jezyk | grep -e "niemiecki" -e "francuski")" != "" ]; then
		export jezyk="english"
		echo 'english' >  /etc/netext73/jezyk
	fi
fi
if [ -e /etc/netext73/jezyk ]; then
	export jezyk=$(cat /etc/netext73/jezyk)
else
	if [ "$(echo $LANG | grep pl)" != "" ]; then
		export jezyk="polski"
		echo 'polski' >  /etc/netext73/jezyk
	elif [ "$(echo $LANG | grep -i ru)" != "" ]; then
		export jezyk="русский"
		echo 'русский' >  /etc/netext73/jezyk
	else
		export jezyk="english"
		echo 'english' >  /etc/netext73/jezyk
	fi
fi
}

przepisanie_configow(){
#katalog dla sysbench
if [ ! -e /var/log/netext73/sysbench ]; then
	mkdir /var/log/netext73/sysbench -p
fi
#katalog dla logów
if [ ! -e /var/log/netext73/logi ]; then
	mkdir /var/log/netext73/logi -p
fi
}

dymek(){
#ekran
display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
#id usera
uid=$(id -u $userek)
if [ "$USER" = "root" ] && [ "$(which kdialog)" != "" ];then
	if [ -e /etc/netext73/notify_fix ] && [ "$(grep TRUE /etc/netext73/notify_fix)" != "" ];then
		sudo -u $userek kdialog --icon "$2" --title "$3" --passivepopup "$4"
	else
		if [ "$(who | grep '('$display')' | awk '{print $1}' | grep "$userek")" != "" ]; then
			sudo -u $userek DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus kdialog --icon "$2" --title "$3" --passivepopup "$4"
		else
			kdialog --icon "$2" --title "$3" --passivepopup "$4"
		fi
	fi
elif [ "$USER" = "root" ] && [ "$(which notify-send)" != "" ] ;then
	if [ "$(who | grep '('$display')' | awk '{print $1}' | grep "$userek")" != "" ];then
		sudo -u $userek DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send "$@"
	else
		notify-send "$@"
	fi
else
	if [ "$(which notify-send)" != "" ];then
		notify-send "$1" "$2" "$3" "$4"
	elif [ "$(which kdialog)" != "" ];then
		kdialog --icon "$2" --title "$3" --passivepopup "$4"
	else
		yad --center --on-top --info --title="$3" --window-icon="$2" --image="$2" --text="$4" --timeout=5 --geometry="$((300*$skala))x$((100*$skala))+15+30" --no-buttons --undecorated
	fi
fi
}


#pobranie tłumaczeń
source /opt/NeteXt73/tlumaczenia/angielski
TEXT_OPIS_APM=/opt/NeteXt73/tlumaczenia/angielski_apm
jezyczek;
case $jezyk in
	pol*) 	source /opt/NeteXt73/tlumaczenia/polski
			TEXT_OPIS_APM=/opt/NeteXt73/tlumaczenia/polski_apm
	;;
	рус*) 	source /opt/NeteXt73/tlumaczenia/russian
			TEXT_OPIS_APM=/opt/NeteXt73/tlumaczenia/russian_apm
	;;
esac

export nazwa_skryptu="NeteXt'73 v$LATEST_VERSION - $TEXT_NETEXT2"
export nazwa_skryptu1="NeteXt'73 v$LATEST_VERSION"
export wersja_mesy='22.x.x'
#lista kerneli premium i standard
export lista_kerneli_premium="silvermont|sandybridge|ivybridge|haswell|broadwell|skylake|kabylake|kabylake-8th|tigerlake|brazos|bulldozer|piledriver|ryzen|ryzen-2|ryzen-3"
export lista_kerneli_standard="intelstandard|amdstandard"
#nazwy ikon do dymków
export error1="dialog-error"
export ikona_info1="dialog-positive"
export warning1="dialog-warning"

export lista_dyskow=$(lsblk | grep disk | awk '{print $1}' | sort | uniq)

#wersja
export WERSJA_UBUNTU="$(lsb_release -cs)"
export NR_WERSJA_UBUNTU="$(lsb_release -rs)"
export wspierane_wersje="jammy|lunar|mantic|noble"
export wspierane_nr="22.04|23.04|23.10|24.04"

#wsparcie mint/elementary os
case `lsb_release -cs` in
#	ulyana|ulyssa|uma|odin|jolnir|una)
#		export WERSJA_UBUNTU="focal"
#		export NR_WERSJA_UBUNTU="20.04" ;;
	horus|vanessa|vera|victoria)
		export WERSJA_UBUNTU="jammy"
		export NR_WERSJA_UBUNTU="22.04" ;;

esac

#adres serwera
export adres_glowny="https://kernele.netext73.com"
export adres_logi="https://netext73.com/htdocs/api/create?apikey=dodawanie_wpisow_2204"
export adres_sterownikow="$adres_glowny/darmowe/sterowniki/"
export adres_sterownikow1="https://launchpad.net/~netext/+archive/ubuntu/nvidia-stable"
export adres_opisu="https://www.netext73.pl/search/label/opis_netext73"

if [ ! -z "$(lspci | grep -E 'VGA|3D' | grep -E 'Intel|AMD|ATI')" ] && [ ! -z "$(lspci | grep -E 'VGA|3D' | grep -E 'NVIDIA|GeForce|Quadro')" ]; then
	export nazwa_sterownika="Nvidia Optimus Prime"
elif [ -z "$(lspci | grep -E 'VGA|3D' | grep -E 'Intel|AMD|ATI')" ] && [ ! -z "$(lspci | grep -E 'VGA|3D' | grep -E 'NVIDIA|GeForce|Quadro')" ]; then
	export nazwa_sterownika="Nvidia"
elif [ -z "$(lspci | grep -E 'VGA|3D' | grep -E 'NVIDIA|GeForce|Quadro')" ]; then
	export nazwa_sterownika="FALSE"
fi
#sumy sumy kontrolne
export katalog2="2"
export sumy_kontrolne='/tmp/netext73/sumy/sumy_kontrolne.txt'
#sprawdzanie platfromy
#cat /sys/devices/cpu/caps/pmu_name
if [ "$(cat /proc/cpuinfo | grep -i Intel)" != "" ]; then
	export komputerek="INTEL"
	if [ "$(cat /sys/devices/cpu/caps/pmu_name | grep -E 'haswell|broadwell|skylake|kabylake|cannonlake|cascadelake|cooperlake|tigerlake|alderlake|rocketlake|icelake')" != '' ];then
		export haswelek="TRUE"
		echo "TRUE" > /etc/netext73/haswelek
		if [ "$(cat /sys/devices/cpu/caps/pmu_name | grep -E 'icelake|tigerlake')" != '' ];then
			export tigerlake="TRUE"
		else
			export tigerlake="FALSE"
		fi
	else
		export haswelek="FALSE"
		export tigerlake="FALSE"
		echo "FALSE" > /etc/netext73/haswelek
	fi
	export komputerek_intel="$(cat /sys/devices/cpu/caps/pmu_name)"
elif [ "$(cat /proc/cpuinfo | grep -i AMD)" != "" ]; then
	export komputerek="AMD"
	#sprawdzanie czy ryzen
	if [ "$(cat /proc/cpuinfo | grep -i 'ryzen')" != "" ]; then
		echo "TRUE" > /etc/netext73/ryzenek
	else
		echo "FALSE" > /etc/netext73/ryzenek
	fi

fi

#apm nowy
export katalog_apm="/etc/apm-ext73/advanced_power_management_by_ext73_*"

export wersja_apm=$(ls /opt/NeteXt73/APM/advanced_power_management_by_ext73_* | cut -d '_' -f 6 | tail -n 1 | sed 's/.tar.xz//')


#premium4free
if [ ! -e /etc/netext73/kernel_premium ]; then
	echo "netext73@forfree@netext73" > /etc/netext73/kernel_premium
	dymek -i $ikona_info1 "$TEXT_INFORMACJA" "$TEXT_PREMIUM_FREE"
fi
#premium
if [ -e /etc/netext73/kernel_premium ]; then
	if [ "$(grep @.*@ /etc/netext73/kernel_premium)" = "" ]; then
		rm -f /etc/netext73/kernel_premium
		export kernel_premium="brak"
	else
		export US1=$(cat /etc/netext73/kernel_premium | cut -d '@' -f 1)
		export PASS1=$(cat /etc/netext73/kernel_premium | cut -d '@' -f 3)
		export kernel_premium="tak"
	fi
fi

#kolor textu
if [ -e /etc/netext73/kolor_textu ]; then
	export kolor_textu=$(cat /etc/netext73/kolor_textu)
else
	export kolor_textu="blue"
fi
if [ -e /tmp/netext73/userek ]; then
	export userek=$(cat /tmp/netext73/userek)
fi
if [ -e /tmp/netext73/userek2 ]; then
	if [ ! -e /etc/netext73/userek ]; then
		md5sum /tmp/netext73/userek2 | cut -d ' ' -f 1 > /etc/netext73/userek
	fi
fi

if [ -e /etc/netext73/userek ]; then
	export userek2=$(cat /etc/netext73/userek)
fi

#adres katalogu download
if [ -e /tmp/netext73/domek ]; then
	export domek=$(cat /tmp/netext73/domek)
fi
if [ -e $domek/Pobrane ]; then
	export download="$domek/Pobrane"
elif [ -e $domek/Download ]; then
	export download="$domek/Downloads"
elif [ -e $domek ];then
	export download="$domek"
else
	export download="/home/$userek"
fi

#HiDPI
if [ -e /etc/netext73/HiDPI ] && [ "$(cat /etc/netext73/HiDPI)" = "TRUE" ]; then
	export skala=2
else
	export skala=1
fi


#########################################################################################################################################################################
#procedury

#pasek postępu pobierania pulsujący gdy coś długo trwa
pobieranie(){
yad --center --on-top --width=$((560*$skala)) --title="  $nazwa_skryptu" --text="$TEXT_POBIERANIE" --progress --pulsate --auto-close --auto-kill --window-icon="/opt/NeteXt73/ikony/download.png" --button="$TEXT_POWROT:1"
}

#pobieranie plików do instalacji kerneli
pobieranie_kerneli(){
#pobieranie kerneli e X t 7 3
nazwa_paczki="$(echo $a | cut -d "_" -f 2)$(echo -$rodzaj'_'amd64.deb)"
yad_wget $strona/$a/linux-headers-$nazwa_paczki $strona/$a/linux-image-$nazwa_paczki
}

please_wait(){
if [ "$1" = "kill" ]; then
	echo "zakoncz czekaj.py" > /tmp/netext73/zakoncz.txt
else
	python3 /opt/NeteXt73/czekaj.py "$TEXT_CZEKAJ_TYTUL" "$TEXT_CZEKAJ_TEXT" &
fi
}

wersja(){
dymek -i "/opt/NeteXt73/ikony/NeteXt73.png" " " "$nazwa_skryptu" #"$TEXT_INFO1"
}

naglowek(){
echo '#!/bin/bash'
}

instaluj_kernel(){
echo "echo \"$TEXT_PROCEDURA_1\""
echo "echo -e \"\$TEXT_INSTALOWAC_KERNEL3 \$rodzaj \$TEXT_INSTALOWAC_KERNEL4\n\n$(ls *.deb)\""
#instalacja kernela
echo "/usr/bin/yes | sudo dpkg -i linux-headers* linux-image*"
echo "if [ -e /etc/netext73/archiwum_deb ] && [ \"\$(cat /etc/netext73/archiwum_deb)\" = \"TRUE\" ]; then"
echo "sudo cp *.deb /var/cache/apt/archives/ -f"
echo "fi"
#broadcom dla apple'a
echo "if [ \"\$(lspci | grep -i bcm | grep -i -E '802.11|wireless')\" != '' ] && [ \"\$(lsusb | grep -i apple)\" != '' ]; then"
#broadcom dla kerneli 5x
echo "if [ \"\$(lspci | grep -i bcm | grep -i -E '802.11|wireless')\" != '' ];then"
echo "dpkg -l | grep broadcom-sta  | awk '{print \$2}' > bc.txt"
echo "dpkg -l | grep bcmwl-kernel-source | awk '{print \$2}' >> bc.txt"
echo "if grep . bc.txt;then"
echo "sudo dpkg -P \$(cat bc.txt | tr '\\n' ' ')"
echo "rm -f bc.txt"
echo "fi"
echo "fi"
echo "sudo apt install firmware-b43-installer firmware-b43legacy-installer b43-fwcutter"
#broadcom dla innych
echo "elif [ \"\$(lspci | grep -i bcm | grep -i -E '802.11|wireless')\" != '' ] && [ \"\$(lsusb | grep -i apple)\" = '' ]; then"
echo "sudo apt install bcmwl-kernel-source -y"
echo "fi"
#modyfikacja wpisów GRUB
#wpis iommu
#echo "if [ \"\$(grep intel_iommu=igfx_off /etc/default/grub)\" = '' ] && [ \"\$komputerek\" = \"INTEL\" ];then"
#echo "sudo sed -i '/GRUB_CMDLINE_LINUX=/ s/\"$/ intel_iommu=igfx_off\"/' /etc/default/grub"
#echo "fi"
#echo "echo 'tak' > /tmp/netext73/ok.txt"
#ryzen
echo "if [ \"\$(grep amd-pstate=active /etc/default/grub)\" = '' ] && [ \"\$(grep TRUE /etc/netext73/ryzenek)\" != '' ];then"
echo "sudo sed -i '/GRUB_CMDLINE_LINUX=/ s/\"$/ amd-pstate=active\"/' /etc/default/grub"
echo "fi"

#initramfs
echo "if [ \"\$(ls -la | grep ext73-)\" != '' ]; then"
echo "sed -i 's/COMPRESS=.*/COMPRESS=zstd/'g /etc/initramfs-tools/initramfs.conf"
echo "else"
echo "sed -i 's/COMPRESS=.*/COMPRESS=gzip/'g /etc/initramfs-tools/initramfs.conf"
echo "fi"
echo "update-initramfs -u"

#preempt
echo "if [ \"\$(grep 'GRUB_CMDLINE_LINUX.*preempt=' /etc/default/grub)\" = '' ];then"
echo "sudo sed -i '/GRUB_CMDLINE_LINUX=/ s/\"$/ preempt=voluntary\"/' /etc/default/grub"
echo "fi"
#usunięcie acpi_enforce_resources=lax
echo "if grep 'acpi_enforce_resources=lax' /etc/default/grub;then"
echo "sed -i 's/acpi_enforce_resources=lax//' /etc/default/grub"
echo "fi"
#usunięcie pcie_port_pm=off
echo "if grep 'pcie_port_pm=off' /etc/default/grub; then"
echo "sudo sed -i 's/pcie_port_pm=off//g' /etc/default/grub"
echo "fi"
#wyłączenie LPT
echo "if [ -e /etc/modules-load.d/cups-filters.conf ]; then"
echo "sudo sed -i '/^[^#]/s:^:#:' /etc/modules-load.d/cups-filters.conf"
echo "fi"
#usunięcie /etc/X11/xorg.conf.d/20-intel.conf dla kerneli v90
echo "if [ \"\$(ls | grep ext73-9)\" != '' ];then"
echo "rm  -f /etc/X11/xorg.conf.d/20-intel.conf"
echo "if [ -e  /etc/netext73/apm_status ]; then"
echo "sed -i 's/intel_fix.*/intel_fix Gallium3D/g' /etc/netext73/apm_status"
echo "fi"
echo "fi"
echo "sudo update-grub"
#ldconfig
echo "sudo ldconfig"
}

#zgoda na wysyłanie raportów
send_raport(){
	ls *.deb > raport.txt
	cat /proc/cpuinfo | grep -E 'model name|flags' | head -n 2 >> raport.txt
	cat raport.txt | netext73-paste2 raport; rm -f raport.txt
#	cat /proc/cpuinfo | grep -E 'flags' | head -n 1 | sed 's/.*: //' | netext73-paste3
}
zgoda_na_raport(){
if [ -e /etc/netext73/zgoda ] && [ "$(grep TRUE /etc/netext73/zgoda)" != '' ]; then
	send_raport
elif [ -e /etc/netext73/zgoda ] && [ "$(grep FALSE /etc/netext73/zgoda)" != '' ]; then
	echo 1 > /dev/null
else
	zgoda_na_raport2
fi
}

zgoda_na_raport2(){
	if yad --center --question --title="$nazwa_skryptu" --window-icon="/opt/NeteXt73/ikony/pytanie.png" --image="/opt/NeteXt73/ikony/pytanie.png" --button="$TEXT_TAK:0" --button="$TEXT_NIE:1" --height=$((180*$skala)) --width=$((290*$skala)) --text="$TEXT_ZGODA" ; then
		echo 'TRUE' > /etc/netext73/zgoda
		send_raport
	else
		echo 'FALSE' > /etc/netext73/zgoda
	fi
}

porownaj_liczby(){
awk 'BEGIN {return_code=('$1' >= '$2') ? 0 : 1; exit} END {exit return_code}'
   return_code=$?
}

instaluj_apm(){
sudo rm -fr /etc/pm/power.d/* /usr/lib/pm-utils/power.d/readahead
sudo chmod a-x /usr/lib/pm-utils/power.d/*
sudo chmod a-x /etc/apm/event.d/20hdparm
sudo rm -f /etc/systemd/system/hibernate.target.wants/apm_ext73.resume.service
sudo rm -f /etc/systemd/system/hybrid-sleep.target.wants/apm_ext73.resume.service
sudo rm -f /etc/systemd/system/suspend.target.wants/apm_ext73.resume.service
sudo rm -f /etc/systemd/system/hibernate.target.wants/apm_ext73-before.service
sudo rm -f /etc/systemd/system/hybrid-sleep.target.wants/apm_ext73-before.service
sudo rm -f /etc/systemd/system/suspend.target.wants/apm_ext73-before.service
sudo rm -f /lib/systemd/system/apm_ext73_resume.service
sudo rm -f /lib/systemd/system-sleep/apm_ext73-before.service
sudo rm -f /etc/udev/rules.d/[0-9][0-9]-wol-udev-apm-ext73.rules
sudo rm -f /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules
sudo rm -f /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
sudo rm -f /etc/udev/rules.d/[0-9][0-9]-xfs-udev-apm-ext73.rules
sudo mkdir -p /etc/apm-ext73
sudo rm -f /etc/apm-ext73/*
sudo mkdir -p /tmp/apm-ext73
sudo rm -f /tmp/apm-ext73/*
tar -Jxf /opt/NeteXt73/APM/advanced_power_management_by_ext73_$wersja_apm.tar.xz -C /tmp/apm-ext73/
if [ ! -e /etc/rc.local ] || [ "$(cat /etc/rc.local | grep '#!/bin/sh -e')" = "" ]; then
	echo '#!/bin/sh -e' > /etc/rc.local
	chmod a+x /etc/rc.local
	chown root:root /etc/rc.local
fi

sudo cp /tmp/apm-ext73/advanced_power_management* /etc/apm-ext73/
sudo cp /tmp/apm-ext73/brightness /etc/apm-ext73/
sudo cp /tmp/apm-ext73/apm_before /etc/apm-ext73/
sudo cp /tmp/apm-ext73/apm_resume /etc/apm-ext73/
sudo cp /tmp/apm-ext73/wol /etc/apm-ext73/
sudo cp /tmp/apm-ext73/xfs_buffer /etc/apm-ext73/
sudo cp /tmp/apm-ext73/ext73_lenovo-hack_turbo.sh /etc/apm-ext73/
sudo chmod a+x /etc/apm-ext73/*
sudo chown root:root /etc/apm-ext73/*
sudo cp /tmp/apm-ext73/*.rules /etc/udev/rules.d/
sudo chown root:root /etc/udev/rules.d/*
sudo chmod 644 /etc/udev/rules.d/*
#APM systemd
sudo cp /tmp/apm-ext73/apm_ext73-resume.service /lib/systemd/system/
sudo cp /tmp/apm-ext73/apm_ext73-before.service /lib/systemd/system-sleep/
sudo chown root:root /lib/systemd/system-sleep/apm_ext73-before.service /lib/systemd/system/apm_ext73-resume.service
sudo chown root:root /etc/systemd/system/hybrid-sleep.target.wants/*
sudo chmod a+x /lib/systemd/system-sleep/apm_ext73-before.service /lib/systemd/system/apm_ext73-resume.service
if [ -e /lib/systemd/system-sleep/wpasupplicant ];then
	sudo sed -i 's/\/sbin\/wpa_cli suspend/\/etc\/apm-ext73\/apm_before/g' /lib/systemd/system-sleep/wpasupplicant
fi
if [ -e /lib/systemd/system-sleep/hdparm ];then
	sudo sed -i 's/\/usr\/lib\/pm-utils\/power.d\/95hdparm-apm resume/echo 1 > \/dev\/null/g' /lib/systemd/system-sleep/hdparm
fi

#udev jeżeli notebook
if [ -e /sys/class/power_supply/BAT*/uevent ]; then
	sudo cp /tmp/apm-ext73/[0-9][0-9]-udev-apm-ext73.rules /etc/udev/rules.d/
	ACAD=$(ls /sys/class/power_supply/ | head -1)
	if [ "$ACAD" != '' ] && [ "$ACAD" != "ACAD" ];then
		sed -i "s/ACAD/$ACAD/g" /etc/udev/rules.d/[0-9][0-9]-wol-udev-apm-ext73.rules
		sed -i "s/ACAD/$ACAD/g" /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules
		sed -i "s/ACAD/$ACAD/g" /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
		sed -i "s/ACAD/$ACAD/g" /etc/udev/rules.d/[0-9][0-9]-xfs-udev-apm-ext73.rules
		sed -i "s/ACAD/$ACAD/g" /etc/apm-ext73/apm_resume
	fi
	katalog="/etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules"
	#dodanie apm fixa do rc.local
	sudo sed -i '/apm_status_fix/d' /etc/rc.local
	sudo sed -i '/exit 0/d' /etc/rc.local
	sudo sed -i '/^[ \t]*$/ d' /etc/rc.local
	echo 'bash /opt/NeteXt73/APM/apm_status_fix' | sudo tee -a /etc/rc.local > /dev/null
	echo 'exit 0' | sudo tee -a /etc/rc.local > /dev/null
else
	#dodanie apm fixa do rc.local
	katalog="/etc/rc.local"
	sudo sed -i '/apm-ext73/d' /etc/rc.local
	sudo sed -i '/apm_status_fix/d' /etc/rc.local
	sudo sed -i '/exit 0/d' /etc/rc.local
	sudo sed -i '/^[ \t]*$/ d' /etc/rc.local
	echo 'bash /opt/NeteXt73/APM/apm_status_fix' | sudo tee -a /etc/rc.local > /dev/null
	echo 'bash /etc/apm-ext73/wol false' | sudo tee -a /etc/rc.local > /dev/null
	echo "bash /etc/apm-ext73/advanced_power_management_by_ext73_v[0-9].[0-9] false" | sudo tee -a /etc/rc.local > /dev/null
	if [ -e /proc/sys/fs/xfs/age_buffer_centisecs ]; then
		echo 'bash /etc/apm-ext73/xfs_buffer false' | sudo tee -a /etc/rc.local > /dev/null
	else
		rm -f /etc/udev/rules.d/[0-9][0-9]-xfs-udev-apm-ext73.rules
	fi
	echo 'exit 0' | sudo tee -a /etc/rc.local > /dev/null
	#usunięcie dla desktop zbędnych reguł udev
	rm -f /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
fi

sudo chown root:root /usr/lib/pm-utils/power.d/*
if [ "$(which journalctl)" != "" ] && [ "$(journalctl -u cron | grep systemd)" != "" ];then
	sudo systemctl disable ondemand 2> /dev/null
	sudo systemctl stop ondemand 2> /dev/null
	if [ -e /etc/init.d/ondemand ]; then
		sudo chmod a-x /etc/init.d/ondemand
	fi
else
	sudo service ondemand stop
	if [ -e /etc/init.d/ondemand ]; then
		sudo chmod a-x /etc/init.d/ondemand
	fi
fi

#naprawa powerbtn
if [ "$(cat /etc/acpi/powerbtn.sh | grep '/usr/.../qdbus')" != "" ]; then
	sudo cp /etc/acpi/powerbtn.sh /etc/acpi/powerbtn.sh.bak -f
	sudo sed -i 's/\/usr\/...\/qdbus/\/usr\/lib\/x86_64-linux-gnu\/qt4\/bin\/qdbus/' /etc/acpi/powerbtn.sh
	if [ "$(cat /etc/acpi/powerbtn.sh | grep '#\/sbin')" = "" ];then
		sudo sed -i '/Power button pressed/ s/\/sbin/#\/sbin/' /etc/acpi/powerbtn.sh
	fi
fi
rm -Rf /tmp/apm-ext73

#profil apm - kasowanie jak błędny
if [ -e /etc/netext73/apm_status ]; then
	aktualny="$(cat /etc/netext73/apm_status | head -n 1)"
	if [ "$aktualny" = "intel-performance" ] || [ "$aktualny" = "intel-powersave" ] || [ "$aktualny" = "conservative-conservative" ] || [ "$aktualny" = "ondemand-ondemand" ] || [ "$aktualny" = "performance-conservative" ] || [ "$aktualny" = "performance-ondemand" ] || [ "$aktualny" = "performance-schedutil" ] || [ "$aktualny" = "schedutil-schedutil" ]; then
		echo "ok" > /dev/null
	else
		rm -f /etc/netext73/apm_status
	fi
fi

#dodanie configu gdy nie istnieje
if [ ! -e /etc/netext73/apm_status ]; then
	mkdir -p /etc/netext73
	echo "ondemand-ondemand" 	> /etc/netext73/apm_status
	echo "hdd_scheduler   none" >> /etc/netext73/apm_status
	echo "ssd_scheduler   none" >> /etc/netext73/apm_status
	echo "mem_sleep  s2idle" >> /etc/netext73/apm_status
	echo "jasnosc	FALSE" 		>> /etc/netext73/apm_status
	echo "wifi_batt_fix   TRUE" >> /etc/netext73/apm_status
	echo "wifi_batt_on    TRUE" >> /etc/netext73/apm_status
	echo "wifi_batt_on    TRUE" >> /etc/netext73/apm_status
	echo "bt_batt_on      TRUE" >> /etc/netext73/apm_status
	echo "rts5139_on      TRUE" >> /etc/netext73/apm_status
	echo "wifi_n_on       TRUE" >> /etc/netext73/apm_status
	echo "turbo_batt_on   TRUE" >> /etc/netext73/apm_status
	echo "turbo_ac_on     TRUE" >> /etc/netext73/apm_status
	echo "vsync_on        TRUE" >> /etc/netext73/apm_status
	echo "stan_samsung    FALSE" >> /etc/netext73/apm_status
	echo "stan_min_free_kbytes FALSE" >> /etc/netext73/apm_status
	echo "pci_bateria	powersave" >> /etc/netext73/apm_status
	echo "pci_ac	performance" >> /etc/netext73/apm_status
fi

#odczytanie jasności
if [ -e /etc/netext73/jasnosc ] && [ "$(cat /etc/netext73/jasnosc)" != "" ] ; then
        wart_batt=$(cat /etc/netext73/jasnosc | awk '{print $1}')
        wart_ac=$(cat /etc/netext73/jasnosc | awk '{print $2}')
        sudo sed -i "/#ac/ s/echo.*>/echo $wart_ac >/" /etc/apm-ext73/brightness
        sudo sed -i "/#bateria/ s/echo.*>/echo $wart_batt >/" /etc/apm-ext73/brightness
	else
		if [ -e /sys/class/backlight ]; then
			katalog_jasnosc=$(ls /sys/class/backlight | head -n 1)
		else
			katalog_jasnosc=""
		fi
		if [ "$katalog_jasnosc" != "" ]; then
				wartosc_bright=$(cat /sys/class/backlight/$katalog_jasnosc/brightness)
				echo "$wartosc_bright $wartosc_bright" > /etc/netext73/jasnosc
                wart_batt=$(cat /etc/netext73/jasnosc | awk '{print $1}')
                wart_ac=$(cat /etc/netext73/jasnosc | awk '{print $2}')
                sudo sed -i "/#ac/ s/echo.*>/echo $wart_ac >/" /etc/apm-ext73/brightness
                sudo sed -i "/#bateria/ s/echo.*>/echo $wart_batt >/" /etc/apm-ext73/brightness
		fi
fi
if [ "$(cat /etc/netext73/apm_status | grep jasnosc | grep TRUE)" != "" ] && [ "$(ls /sys/class/backlight | head -n 1)" != "" ]; then
        sudo sed -i 's/.*#SUBSYSTEM/SUBSYSTEM/g' /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
else
        sudo sed -i 's/.*SUBSYSTEM/#SUBSYSTEM/g' /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
fi

#/lib/udev/hdparm
cd /lib/udev
rm -f hdparm.tar.gz
tar -zcvf hdparm.tar.gz hdparm
rm -f hdparm
sudo udevadm trigger --action=add
sudo systemctl start apm_ext73-resume.service
sudo systemctl enable apm_ext73-resume.service
cd /tmp/netext73
#profil apm
sudo sed -i "s/_v.* /_$wersja_apm /g" /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules
sudo sed -i "s/_v.* /_$wersja_apm /g" /etc/rc.local
sudo udevadm control --reload-rules
}

apm_zmiana(){
#profil apm

sudo sed -i "s/_v.* /_$wersja_apm /g" /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules
sudo sed -i "s/_v.* /_$wersja_apm /g" /etc/rc.local
sudo udevadm control --reload-rules

if [ -e /sys/class/power_supply ] && [ "$(cat /sys/class/power_supply/*/online | head -n 1)" = "0" ]; then
	sudo /etc/apm-ext73/./advanced_power_management_by_ext73_v[0-9].[0-9] true
else
	sudo /etc/apm-ext73/./advanced_power_management_by_ext73_v[0-9].[0-9] false
fi

#zastosowanie zmiany czeka jasności
sed -i "s/jasnosc.*/jasnosc	$jasnosc_dziala/g" /etc/netext73/apm_status
if [ "$(cat /etc/netext73/apm_status | grep jasnosc | grep TRUE)" != "" ] && [ "$(ls /sys/class/backlight | head -n 1)" != "" ]; then
	if [ -e /etc/netext73/jasnosc ] && [ "$(cat /etc/netext73/jasnosc)" != "" ] ; then
        wart_batt=$(cat /etc/netext73/jasnosc | awk '{print $1}')
		wart_ac=$(cat /etc/netext73/jasnosc | awk '{print $2}')
		sudo sed -i "/#ac/ s/echo.*>/echo $wart_ac >/" /etc/apm-ext73/brightness
        sudo sed -i "/#bateria/ s/echo.*>/echo $wart_batt >/" /etc/apm-ext73/brightness
	fi
	if [ "$(cat /sys/class/power_supply/*/online | head -n 1)" = "0" ];then
		sudo /etc/apm-ext73/./brightness true
	else
		sudo /etc/apm-ext73/./brightness false
	fi
	sudo sed -i 's/.*#SUBSYSTEM/SUBSYSTEM/g' /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
else
	sudo sed -i 's/.*SUBSYSTEM/#SUBSYSTEM/g' /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules
fi

#intel_fix
if [ -e /etc/netext73/apm_status ] && [ "$(cat /etc/netext73/apm_status | grep intel_fix | grep 'i915 DRI')" != '' ];then
	mkdir -p /etc/X11/xorg.conf.d/
	cp -f /opt/NeteXt73/pakiety/20-intel.conf /etc/X11/xorg.conf.d/20-intel.conf
	if [ "$(cat /etc/netext73/apm_status | grep intel_fix | awk '{print $3}')" = "DRI3" ];then
		sed -i 's/2/3/g' /etc/X11/xorg.conf.d/20-intel.conf
	elif [ "$(cat /etc/netext73/apm_status | grep intel_fix | awk '{print $3}')" = "DRI2" ];then
		sed -i 's/3/2/g' /etc/X11/xorg.conf.d/20-intel.conf
	fi
else
	rm -f /etc/X11/xorg.conf.d/20-intel.conf
fi
}

stan_apm(){
twoj_apm=$(ls /etc/apm-ext73/advanced_power_management_by_ext73_* | cut -d '_' -f 6 | tail -n 1)

if [ -e /etc/apm-ext73/ ] && [ "$(ls /etc/apm-ext73/ | grep lenovo)" != "" ]; then
	if [ "$(ls /etc/apm-ext73/ | wc -l)" != "7" ] || [ "$twoj_apm" != "$wersja_apm" ] ; then
		stan_apm="-"
	fi
elif [ -e /etc/apm-ext73/ ] && [ "$(ls /etc/apm-ext73/ | wc -l)" != "7" ] || [ "$twoj_apm" != "$wersja_apm" ] ; then
	stan_apm="-"
else
	if [ -e /sys/class/power_supply/BAT*/uevent ]; then
		if [ "$(grep advanced_power_management /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules)" != "" ] && [ -e /etc/netext73/apm_status ]; then
			stan_apm=$(cat /etc/netext73/apm_status | head -n 1)
		else
			stan_apm="-"
		fi
	else
		#desktop
		if  [ "$(grep advanced_power_management /etc/rc.local)" != "" ] && [ "$(grep advanced_power_management /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules)" != "" ] && [ -e /etc/netext73/apm_status ]; then
			stan_apm=$(cat /etc/netext73/apm_status | head -n 1)
		else
			stan_apm="-"
		fi
	fi

fi

if [ "$(grep apm_status_fix /etc/rc.local)" = "" ] || [ "$twoj_apm" != "$wersja_apm" ]; then
	    stan_apm="-"
fi
}

stan_apm_config(){
#wysłanie danych do configu
	export aktualny_apm="$(cat /etc/netext73/apm_status | head -n 1)"
	export wifi_batt_fix="$(grep wifi_batt_fix /etc/netext73/apm_status | awk '{print $2}')"
	export wifi_batt_on="$(grep wifi_batt_on /etc/netext73/apm_status | awk '{print $2}')"
	export mem_sleep="$(grep mem_sleep /etc/netext73/apm_status | awk '{print $2}')"
	export bt_batt_on="$(grep bt_batt_on /etc/netext73/apm_status | awk '{print $2}')"
	export rts5139_on="$(grep rts5139_on /etc/netext73/apm_status | awk '{print $2}')"
	export wifi_n_on="$(grep wifi_n_on /etc/netext73/apm_status | awk '{print $2}')"
	export turbo_batt_on="$(grep turbo_batt_on /etc/netext73/apm_status | awk '{print $2}')"
	export turbo_batt_on="$(grep turbo_batt_on /etc/netext73/apm_status | awk '{print $2}')"
	export turbo_ac_on="$(grep turbo_ac_on /etc/netext73/apm_status | awk '{print $2}')"
	export vsync_on="$(grep vsync_on /etc/netext73/apm_status | awk '{print $2}')"
	export stan_samsung="$(grep stan_samsung /etc/netext73/apm_status | awk '{print $2}')"
	export stan_min_free_kbytes="$(grep stan_min_free_kbytes /etc/netext73/apm_status | awk '{print $2}')"
	export pci_bateria="$(grep pci_bateria /etc/netext73/apm_status | awk '{print $2}')"
	export pci_ac="$(grep pci_ac /etc/netext73/apm_status | awk '{print $2}')"
	export stan_apm_pci="$(grep stan_apm_pci /etc/netext73/apm_status | awk '{print $2}')"
	export jasnosc_dziala="$(cat /etc/netext73/apm_status | grep jasnosc | awk '{print $2}')"
	export stan_intel_fix="$(cat /etc/netext73/apm_status | grep intel_fix | awk '{print $2}')"
    export katalog_jasnosc="$(ls /sys/class/backlight | head -n 1)"


	#schedulery
	if [ "$(grep ssd_schedule /etc/netext73/apm_status | awk '{print $2}')" != "" ];then
		export ssd_scheduler="$(cat /etc/netext73/apm_status | grep ssd_schedule | awk '{print $2}')"
	else
		export ssd_scheduler="none"
	fi
	if [ "$(grep hdd_schedule /etc/netext73/apm_status | awk '{print $2}')" != "" ];then
		export hdd_scheduler="$(cat /etc/netext73/apm_status | grep hdd_schedule | awk '{print $2}')"
	else
		export hddd_scheduler="none"
	fi
	lista_planistow=''
	if [ "$(ls /dev/ | grep sd[a-z])" != "" ]; then
		lista_planistow=$(cat /sys/block/sd*/queue/scheduler | head -n 1 | sed 's/\[//g' | sed 's/\]//g')
	fi
	if [ "$lista_planistow" = '' ]; then
		lista_planistow=$(cat /sys/block/nvme*/queue/scheduler | head -n 1 | sed 's/\[//g' | sed 's/\]//g')
	fi
	#sprawdzenie BFQ/CFQ/deadline HDD

	if [ "$(ls /dev/ | grep sd[a-z])" != '' ] || [ "$(ls /sys/block/nvme*/queue/scheduler)" != '' ]; then
		lista_ssd=$(echo $lista_planistow | sed "s/$ssd_scheduler//" | sed 's/ /!/g' | sed 's/!!/!/g')
		export ssd_scheduler_menu=$(echo $ssd_scheduler' '$lista_ssd | sed 's/ /!/g' | sed 's/!!/!/g'| sed '$s/!$//')
		lista_hdd=$(echo $lista_planistow | sed "s/$hdd_scheduler//" | sed 's/ /!/g' | sed 's/!!/!/g')
		export hdd_scheduler_menu=$(echo $hdd_scheduler' '$lista_hdd | sed 's/ /!/g' | sed 's/!!/!/g'| sed '$s/!$//')
	fi
#	export mem_sleep_przed=$mem_sleep
#	export jasnosc_dziala_przed=$jasnosc_dziala
#	export wifi_n_on_przed=$wifi_n_on
#	export wifi_batt_fix_przed=$wifi_batt_fix
#	export wifi_batt_on_przed=$wifi_batt_on
#	export bt_batt_on_przed=$bt_batt_on
#	export rts5139_on_przed=$rts5139_on
#	export hdd_scheduler_przed=$hdd_scheduler
#	export ssd_scheduler_przed=$ssd_scheduler
#	export turbo_batt_on_przed=$turbo_batt_on
#	export turbo_ac_on_przed=$turbo_ac_on
#	export vsync_on_przed=$vsync_on
#	export stan_samsung_przed=$stan_samsung
#	export stan_min_free_kbytes_przed=$stan_min_free_kbytes
#	export pci_bateria_przed=$pci_bateria
#	export pci_ac_przed=$pci_ac
#	export stan_apm_pci_przed=$stan_apm_pci
#	export stan_intel_fix_przed=$stan_intel_fix

}

usun_apm(){
echo "echo \"$TEXT_PROCEDURA_9\""
echo "sudo systemctl stop apm_ext73-resume.service"
echo "sudo systemctl disable apm_ext73-resume.service"
echo "sudo rm -f /lib/systemd/system/apm_ext73-resume.service"
echo "sudo rm -f /lib/systemd/system-sleep/apm_ext73-before.service"
echo "sudo rm -f /etc/systemd/system/hibernate.target.wants/apm_ext73*"
echo "sudo rm -f /etc/systemd/system/hybrid-sleep.target.wants/apm_ext73*"
echo "sudo rm -f /etc/systemd/system/suspend.target.wants/apm_ext73*"
echo "sudo rm -f /etc/udev/rules.d/[0-9][0-9]-wol-udev-apm-ext73.rules"
echo "sudo rm -f /etc/udev/rules.d/[0-9][0-9]-udev-apm-ext73.rules"
echo "sudo rm -f /etc/udev/rules.d/[0-9][0-9]-brightness-udev-apm-ext73.rules"
echo "sudo rm -f /etc/udev/rules.d/[0-9][0-9]-xfs-udev-apm-ext73.rules"
echo "sudo rm -rf /etc/apm-ext73"
echo "sudo sed -i '/apm_status_fix/d' /etc/rc.local"
echo "sudo rm -fr /etc/pm/power.d/advanced_power_management_by_ext73* /usr/lib/pm-utils/power.d/readahead"
echo "sudo chmod a+x /usr/lib/pm-utils/power.d/*"
echo "if [ -e /etc/apm/event.d/20hdparm ]; then"
echo "sudo chmod a+x /etc/apm/event.d/20hdparm"
echo "sudo chown root:root /etc/apm/event.d/20hdparm"
echo "fi"
echo "sudo chown root:root /usr/lib/pm-utils/power.d/*"
echo "sudo sed -i 's/echo 1 > \/dev\/null/\/usr\/lib\/pm-utils\/power.d\/95hdparm-apm resume/g' /lib/systemd/system-sleep/hdparm"
echo "if [ -e /lib/systemd/system-sleep/wpasupplicant ]; then"
echo "sudo sed -i 's/\/etc\/apm-ext73\/apm_before/\/sbin\/wpa_cli suspend/g' /lib/systemd/system-sleep/wpasupplicant"
echo "fi"
#przywrócenie powerbtn
echo "if [ -e /etc/acpi/powerbtn.sh.bak ]; then"
echo "sudo mv /etc/acpi/powerbtn.sh.bak /etc/acpi/powerbtn.sh -f"
echo "sudo chmod a+x /etc/acpi/powerbtn.sh"
echo "sudo chown root:root /etc/acpi/powerbtn.sh"
echo "fi"
echo "if [ \"\$(which journalctl)\" != \"\" ] && [ \"\$(journalctl -u cron | grep systemd)\" != \"\" ];then"
echo "if [ -e /etc/init.d/ondemand ]; then"
echo "sudo chmod a+x /etc/init.d/ondemand"
echo "fi"
echo "sudo systemctl enable ondemand 2> /dev/null"
echo "sudo systemctl start ondemand 2> /dev/null"
echo "else"
echo "if [ -e /etc/init.d/ondemand ]; then"
echo "sudo chmod a+x /etc/init.d/ondemand"
echo "fi"
echo "sudo service ondemand start"
echo "fi"
echo "sudo sed -i '/apm_status_fix/d' /etc/rc.local"
#usunięcie hibernacji
echo "if [ -e /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla ]; then"
echo "sudo rm -f /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla"
echo "fi"
#usunięcie wpisów rc.local
echo "sudo sed -i '/apm-ext73/d' /etc/rc.local"
echo "sudo sed -i '/apm_status_fix/d' /etc/rc.local"
echo "sudo sed -i '/exit 0/d' /etc/rc.local"

#/lib/udev/hdparm
echo "cd /lib/udev"
echo "if [ -e /lib/udev/hdparm.tar.gz ]; then"
echo "rm -f hdparm"
echo "tar -zxvf hdparm.tar.gz"
echo "rm -f hdparm.tar.gz"
echo "sudo udevadm trigger --action=add"
echo "cd /tmp/netext73"
echo "fi"
}

usun_kernel(){
echo "echo \"$TEXT_KERNEL1\""
echo "echo \"$(cat /tmp/netext73/kasuj.txt)\""
echo "sudo dpkg -P $(cat /tmp/netext73/kasuj.txt  | tr '\n' ' ')"
echo "sudo update-grub"
echo "rm /tmp/netext73/*.txt -f; rm /tmp/netext73/*.sh -f"
}

#data i godzina
data_godzina(){
	export godzina=$(date +\"%Y%m%d_%H%m%S\")
}

#instalacja za chwile nastąpi wprowadzenie zmian
instalacja(){
if [ "$(lsof /var/lib/dpkg/lock)" != "" ];then
	proces_zablokowany
else
	data_godzina
	if [ "$1" = "" ]; then
		tekst_instalatora="instalator"
	else
		tekst_instalatora="$1"
	fi
	xterm -T "$tekst_instalatora" -e bash -c "sudo cp -f instaluj.sh /var/log/netext73/logi/instalujsh_$godzina.log && tput setaf 1;echo \"$TEXT_INSTALACJA1\";tput sgr0; bash instaluj.sh 2>&1 | sudo tee -a /var/log/netext73/logi/instalacja_$godzina.log && rm instaluj.sh -f ;tput setaf 2; echo -e \"$TEXT_INSTALACJA2\"; echo 'tak' > /tmp/netext73/ok.txt;sleep 5"
	blad_instalacji instalujsh_$godzina.log instalacja_$godzina.log
fi
}

#instalacja bez pytań
instalacja2(){
if [ "$(lsof /var/lib/dpkg/lock)" != "" ];then
	proces_zablokowany
else
	data_godzina
	if [ "$1" = "" ]; then
		tekst_instalatora="instalator"
	else
		tekst_instalatora="$1"
	fi
	xterm -T "$tekst_instalatora" -e bash -c "cp -f instaluj.sh /var/log/netext73/logi/instalujsh_$godzina.log && bash instaluj.sh 2>&1 | tee -a /var/log/netext73/logi/instalacja_$godzina.log && rm instaluj.sh -f && echo 'tak' > /tmp/netext73/ok.txt"
	blad_instalacji instalujsh_$godzina.log instalacja_$godzina.log
fi
}

#instalacja wciśnij enter
instalacja3(){
if [ "$(lsof /var/lib/dpkg/lock)" != "" ];then
	proces_zablokowany
else
	data_godzina
	if [ "$1" = "" ]; then
		tekst_instalatora="instalator"
	else
		tekst_instalatora="$1"
	fi
	xterm -T "$tekst_instalatora" -e bash -c "cp -f instaluj.sh /var/log/netext73/logi/instalujsh_$godzina.log && sudo bash instaluj.sh 2>&1 | tee -a /var/log/netext73/logi/instalacja_$godzina.log && rm instaluj.sh -f ;tput setaf 2; echo -e \"$TEXT_INSTALACJA2\"; read ent; echo 'tak' > /tmp/netext73/ok.txt"
	blad_instalacji instalujsh_$godzina.log instalacja_$godzina.log
fi
}

blad_instalacji(){
KEY3="$(echo $RANDOM)"
#czyszczenie z "
instalujsh=$(echo $1 | sed 's/"//g')
instalacja=$(echo $2 | sed 's/"//g')
if [ "$(cat /var/log/netext73/logi/instalacja | grep -i -x -E "error|fail")" != "" ]; then
	#zmienne losowe
	res[0]=$(mktemp --tmpdir=/tmp/netext73 netext73_0.XXXXXXXX)
	res[1]=$(mktemp --tmpdir=/tmp/netext73 netext73_1.XXXXXXXX)
	yad --plug=$KEY3 --tabnum=1 --text-info --filename="/var/log/netext73/logi/$instalacja" 1> ${res[0]} &
	yad --plug=$KEY3 --tabnum=2 --text-info --filename="/var/log/netext73/logi/$instalujsh" 1> ${res[1]} &
	yad --notebook --key=$KEY3 --center --title="$nazwa_skryptu1 - ERROR !" --tab="install ERROR !" --tab="instalujsh" --window-icon="/opt/NeteXt73/ikony/logi.png" --image="/opt/NeteXt73/ikony/logi.png" --on-top --width=$((860*$skala)) --height=$((640*$skala)) --button="$TEXT_PASTEBIN:0" --button="$TEXT_ZAMKNIJ:1"
	klawisz=$?
	if [ "$klawisz" = "0" ]; then
		please_wait
		export userek=$(cat /tmp/netext73/userek)
		cat /var/log/netext73/logi/$instalujsh | pastebinit_netext73 $instalujsh && log1="instalujsh.log"
		cat /var/log/netext73/logi/$instalacja | pastebinit_netext73 $instalacja && log2="instalacja.log"
		wyslane_logi=$(echo $log1 $log2 | tr ' ' '\n')
		dymek -i $ikona_info1 "$TEXT_INFORMACJA" "$TEXT_PRZESLIJ_LOGI :\n$wyslane_logi"
		please_wait kill
	fi
	for i in $(seq 0 1); do
		rm {res[$i]} -f
	done
fi
}

pobieranie_listy_kerneli(){
cd /tmp/netext73
wget $adres_glowny/darmowe/dostepne_kernele.tar.gz 2> /dev/null && dymek -i $ikona_info1 "$TEXT_SUMY_KONTROLNE" "$TEXT_POBIERANIE_GOTOWE"
tar -xzf dostepne_kernele.tar.gz -C /tmp/netext73/sumy/
rm -f dostepne_kernele.tar.gz

}

lista_kerneli(){
cd /tmp/netext73
if [ "$1" = "update" ]; then
	if [ ! -e /tmp/netext73/sumy/kernel_premium.txt ] || [ ! -e /tmp/netext73/sumy/kernel_standard.txt ]; then
		pobieranie_listy_kerneli
	fi
	#sprawdzanie połączenia z netem
	if [ "$(cat /tmp/netext73/sumy/kernel_standard.txt)" = '' ] || [ "$(cat /tmp/netext73/sumy/kernel_premium.txt)" = '' ]; then
		yad --center --on-top --info --title="$nazwa_skryptu   " --text="<span color=\"$kolor_textu\"><b>$BRAKNETA</b></span>" --window-icon="/opt/NeteXt73/ikony/error.png" --image="/opt/NeteXt73/ikony/error.png" --button="gtk-ok:0" --on-top
		exit 1
	fi
else
	echo $kern > /etc/netext73/instalator_kerneli #zapamiętanie wybranego kernela
	if [ "$premium" = "tak" ] && [ "$kernel_premium" = "tak" ]; then
		strona="$adres_glowny/platne/kernele_premium$katalog2/"
		lista_kerneli_ftp="/tmp/netext73/sumy/kernel_premium.txt"
	else
		strona="$adres_glowny/darmowe/kernele/"
		lista_kerneli_ftp="/tmp/netext73/sumy/kernel_standard.txt"
	fi
	#jeżeli brak wersji to ściągamy
	if [ ! -e /tmp/netext73/sumy/kernel_premium.txt ] || [ ! -e /tmp/netext73/sumy/kernel_standard.txt ]; then
		pobieranie_listy_kerneli
	fi
	#dodatkowa walidacja ze względu na podobną nazwę kabylake i ryzen
	if [ "$rodzaj" = "kabylake" ];then
		dpkg -l | grep -E "linux-image.*$rodzaj" | awk '{print $2}' | grep -v th | sed 's/linux-image-//g'  > 3.txt
	elif [ "$rodzaj" = "ryzen" ];then
		dpkg -l | grep -E "linux-image.*$rodzaj" | awk '{print $2}' | grep -v '-2' | sed 's/linux-image-//g'  > 3.txt
	else
		dpkg -l | grep -E "linux-image.*$rodzaj" | awk '{print $2}' | sed 's/linux-image-//g'  > 3.txt
	fi
	cat $lista_kerneli_ftp | cut -d '_' -f 1 | sed 's/v//g' | awk -F. '{print $1,$2}' | sort -r -nk1 -nk2 | sed 's/ /./' > lista_kerneli.txt
	touch 4.txt
	for kernelek in $(cat lista_kerneli.txt ); do
		kernel=$(cat $lista_kerneli_ftp | grep $kernelek | tail -n 1 )
		if [ "$(grep $kernel 4.txt)" = "" ];then
			echo "$kernel" >> 4.txt
			if [ -s 3.txt ]; then
				for kernel1 in $(cat 3.txt ); do
					if [ "$(echo $kernel | grep $(echo $kernel1 | sed "s/-$rodzaj.*//g"))" != "" ]; then
						sed 4.txt -i -e "s/$kernel/$kernel $TEXT_TAK/g"
					fi
				done
			fi
		fi
	done
	cat 4.txt | awk '{print $2}' > stan.txt
	sed -i 's/^[ \t]*$/-/' stan.txt
	cat 4.txt | awk '{print $1}' > lista.txt
	paste -d " " lista.txt stan.txt > 3.txt
	echo $(sed -e '/^[^#]/s:^:FALSE :' 3.txt) > 1.txt
	lista=$(sed  's/FALSE/TRUE/' 1.txt ); rm *.txt -f
	a1="-"
	blad=0
	if [ "$(echo $lista)" = "TRUE" ]; then
		yad --center  --on-top --info --title="$nazwa_skryptu"  --window-icon="/opt/NeteXt73/ikony/info.png" --image="/opt/NeteXt73/ikony/info.png" --button="gtk-ok:0"  --timeout=15 --text="$TEXT_SERVER_ERROR"
		blad=1
	else
		aa=$(yad --center  --close-on-unfocus --on-top --height=$((340*$skala)) --width=$((790*$skala)) --window-icon="/opt/NeteXt73/ikony/linux.png" --title="$nazwa_skryptu" --text="$TEXT_PLATFORMA1: <b><span color=\"$kolor_textu\">$rodzaj</span></b>$TEXT_PLATFORMA2" --column="$TEXT_ZAZNACZ" --column="$TEXT_WYBIERZ_KERNEL" --column="$TEXT_ZNITY1" --button="gtk-ok:0" --button="$TEXT_POWROT:1" --list --radiolist $lista)
		klawisz=$?
		a=$(echo $aa | cut -d "|" -f 2)	 #wybrany kernel
		a1=$(echo $aa | cut -d "|" -f 3) #czy zainstalowany jeżeli '-' można instalować
	fi
fi
}

sprawdz_kernel(){
lista_kerneli update
if [ "$(uname -r | grep ext )" != "" ];then
	twoj_kernel="e X t 7 3 v$(uname -r| cut -d "-" -f 3)"
else
	twoj_kernel=$(uname -r)
fi
if [ "$kernel_premium" = "tak" ]; then
	nowy_kernel=$(cat /tmp/netext73/sumy/kernel_premium.txt | cut -d '_' -f 1 | sed 's/v//g' | awk -F. '{print $1,$2}' |sort -r -nk1 -nk2|sed 's/ /./' | head -n 1 )
else
	nowy_kernel=$(cat /tmp/netext73/sumy/kernel_standard.txt | cut -d '_' -f 1 | sed 's/v//g' | awk -F. '{print $1,$2}' |sort -r -nk1 -nk2|sed 's/ /./' | head -n 1 )
fi
kern1="$(echo $nowy_kernel | sed 's/_testowy.*//g' | sed 's/_stabilny.*//g' | cut -d "-" -f 3)"
kern2="$(echo $nowy_kernel | cut -d "-" -f 1 )"
}

grub(){
echo "echo \"$TEXT_PROCEDURA_13\""
echo "echo \"$TEXT_GRUB1 /etc/default/grub\"; sudo sed -i '/^GRUB_CMDLINE_LINUX=/d' $sciezka/grub"
echo "echo \"$TEXT_GRUB2 /etc/default/grub\"; sudo sed \"/^GRUB_CMDLINE_LINUX_DEFAULT/a\GRUB_CMDLINE_LINUX=\\\"$wpis_grub\\\"\" $sciezka/grub > /tmp/netext73/grub1"
echo "sudo mv /tmp/netext73/grub1 $sciezka/grub -f"
echo "if [ \"\$grub_pro\" != \"tak\" ]; then"
echo "if [ \"\$w3\" = \"0\" ]; then"
echo "sudo sed -i 's/.*GRUB_HIDDEN_TIMEOUT=/GRUB_HIDDEN_TIMEOUT=/g' /etc/default/grub"
echo "sudo sed -i 's/.*GRUB_TIMEOUT_STYLE=/GRUB_TIMEOUT_STYLE=/g' /etc/default/grub"
echo "else"
echo "if [ \"\$(cat /etc/default/grub | grep '#GRUB_HIDDEN_TIMEOUT=')\" = \"\" ]; then"
echo "sudo sed -i 's/.*GRUB_HIDDEN_TIMEOUT=/#GRUB_HIDDEN_TIMEOUT=/g' /etc/default/grub"
echo "sudo sed -i 's/.*GRUB_TIMEOUT_STYLE=/#GRUB_TIMEOUT_STYLE=/g' /etc/default/grub"
echo "fi"
echo "fi"
echo "if [ \"\$w3\" != \"\" ]; then"
echo "sudo sed /etc/default/grub -i -e \"s/GRUB_TIMEOUT=.*/GRUB_TIMEOUT=$w3/\""
echo "fi"
echo "sudo sed -i -e \"s/.*GRUB_GFXMODE=.*/GRUB_GFXMODE=$w4/\" /etc/default/grub"
echo "if [ \"\$w5\" != \"\" ];then"
echo "sudo sed -i -e \"s/.*GRUB_GFXPAYLOAD_LINUX=.*/GRUB_GFXPAYLOAD_LINUX=$w5/\" /etc/default/grub"
echo "fi"
echo "sudo sed -i '/GRUB_BACKGROUND/ d'  /etc/default/grub"
echo "if [ \"\$grub_back\" = \"TRUE\" ]; then"
echo "echo 'GRUB_BACKGROUND=/opt/NeteXt73/ikony/grub_background.png' | sudo tee -a /etc/default/grub"
echo "fi"
echo "fi"
echo "if [ \"\$starter\" != \"default\" ];then"
echo "sudo sed -i -e \"s/GRUB_DEFAULT=.*/GRUB_DEFAULT=\\\"$wpis_nowy\\\"/\" /etc/default/grub"
echo "else"
echo "sudo sed -i -e \"s/GRUB_DEFAULT=.*/GRUB_DEFAULT=0/\" /etc/default/grub"
echo "fi"
echo "sudo chown root:root /etc/default/grub"
#nogpumanager
echo "sudo sed -i 's/nogpumanager//g' /etc/default/grub"
#ryzen
echo "if [ \"\$(grep amd-pstate=active /etc/default/grub)\" = '' ] && [ \"\$(grep TRUE /etc/netext73/ryzenek)\" != '' ];then"
echo "sudo sed -i '/GRUB_CMDLINE_LINUX=/ s/\"$/ amd-pstate=active\"/' /etc/default/grub"
echo "fi"
#wpis nvidia-drm.modeset=1
echo "if [ \"\$(lspci | grep -i VGA | grep -i Intel)\" != '' ] && { [ \"\$(lspci | grep -i GeForce | grep -i NVIDIA)\" != '' ] || [ \"\$(lspci | grep -i NVIDIA | grep -i Quadro)\" != '' ]; };then"
#sprawdzanie wersji kerneli
echo "if [ \"\$(grep nvidia-drm.modeset=1 /etc/default/grub)\" != '' ];then"
echo "sudo sed -i '/GRUB_CMDLINE_LINUX=/ s/nvidia-drm.modeset=1//' /etc/default/grub"
echo "fi"
echo "fi"
echo "sudo update-grub"
echo "echo 'tak' > /tmp/netext73/ok.txt"

}

instaluj_grub(){
echo "echo \"$TEXT_PROCEDURA_13\""
echo "nie" > /tmp/netext73/ok.txt
naglowek > /tmp/netext73/instaluj.sh
grub >> /tmp/netext73/instaluj.sh
instalacja2
if [ "$(cat /tmp/netext73/ok.txt)" = "tak" ]; then
	dymek -i $ikona_info1 "$TEXT_INFORMACJA" "$TEXT_GRUB2 $sciezka/grub. $TEXT_WYMAGANY_RESTART"
else
	dymek -i $warning1 "$TEXT_UWAGA" "$TEXT_GRUB3"
fi
}

usun_pobrane_pliki_kernela(){
if [ "$(cat /tmp/netext73/ok.txt)" = "tak" ]; then
	#dymek -i $ikona_info1 "$TEXT_INFORMACJA" "$TEXT_KERNEL2"
	#yad --center --on-top --info --title="$nazwa_skryptu"  --window-icon="/opt/NeteXt73/ikony/info.png" --image="/opt/NeteXt73/ikony/info.png" --button="gtk-ok:0"  --timeout=15 --text="$TEXT_KERNEL2"
	rm -rf $PWD
elif  [ "$(cat /tmp/netext73/ok.txt)" = "nie" ]; then
	dymek -i $ikona_info1 "$TEXT_UWAGA" "$TEXT_INFO2<br>/tmp/netext73/$a"
fi
rm -f /tmp/netext73/ok.txt
}

nvidia_naglowek(){
echo "clear"
echo "echo \"$TEXT_STEROWNIKI2 Nvidia\""
echo "echo \"$TEXT_POBIERANIE\""
#pobieranie sterowników z repozytorium
echo "for i in \$(curl -s $adres_sterownikow1/+packages?batch=200 | grep sourcepub | cut -d '\"' -f 4); do"
echo "if [ \"\$(curl -s $adres_sterownikow1/\$i | grep nvidia-driver-$wersja_sterownika | grep $NR_WERSJA_UBUNTU | grep deb)\" != '' ]; then"
echo "wget \$(curl -s $adres_sterownikow1/\$i | grep deb | cut -d '\"' -f 2 | grep -E \"libnvidia-cfg1-$wersja_sterownika|libnvidia-common-$wersja_sterownika|libnvidia-compute-$wersja_sterownika|libnvidia-compute-$wersja_sterownika:i386|libnvidia-decode-$wersja_sterownika|libnvidia-decode-$wersja_sterownika:i386|libnvidia-encode-$wersja_sterownika|libnvidia-encode-$wersja_sterownika:i386|libnvidia-extra-$wersja_sterownika|libnvidia-fbc1-$wersja_sterownika|libnvidia-fbc1-$wersja_sterownika:i386|libnvidia-gl-$wersja_sterownika|libnvidia-gl-$wersja_sterownika:i386|nvidia-compute-utils-$wersja_sterownika|nvidia-dkms-$wersja_sterownika|nvidia-driver-$wersja_sterownika|nvidia-kernel-common-$wersja_sterownika|nvidia-kernel-source-$wersja_sterownika|nvidia-utils-$wersja_sterownika|xserver-xorg-video-nvidia-$wersja_sterownika\"  | grep -v open)"
echo "fi"
echo "clear"
echo "echo \"$TEXT_STEROWNIKI2 Nvidia-settings\""
echo "echo \"$TEXT_POBIERANIE\""
#pobieranie nvidia-firmware
echo "if [ \"\$(curl -s $adres_sterownikow1/\$i | grep nvidia-firmware-$wersja_sterownika | grep $NR_WERSJA_UBUNTU | grep deb)\" != '' ]; then"
echo "wget \$(curl -s $adres_sterownikow1/\$i | grep deb | cut -d '\"' -f 2 | grep \"nvidia-firmware-$wersja_sterownika\" | grep -v open)"
echo "fi"
#pobieranie settings
echo "if [ \"\$(curl -s $adres_sterownikow1/\$i | grep nvidia-settings | grep $NR_WERSJA_UBUNTU | grep deb)\" != '' ]; then"
echo "wget \$(curl -s $adres_sterownikow1/\$i | grep deb | grep amd64 | cut -d '\"' -f 2 | grep -E \"nvidia-settings|libxnvctrl0\")"
echo "fi"
echo "done"
#pobieranie 23 plików dla 535 - 24 pliki dla 545
echo "ls -ls | grep deb"
echo "liczba plików :"
echo "ls | grep deb | wc -l"
echo "ilosc_plikow=$(ls | grep deb | wc -l)"
echo "if [ \"\$(ls | grep nvidia-firmware)\" != '' ]; then"
echo "jest_plikow='24'"
echo "else"
echo "jest_plikow='23'"
echo "fi"
echo "if [ $ilosc_plikow != $jest_plikow ]; then"
echo "clear"
echo "echo \"$TEXT_BLAD_POBIERANIA\""
echo "sleep 10"
echo "echo 1 > /tmp/blad_instalacji"
echo "exit 1"
echo "fi"
#usuwanie starych sterowników
echo "clear"
echo "echo \"$TEXT_PROCEDURA_16\""
echo "dpkg -l | grep nvidia  | awk '{print \$2}' > nv.txt"
echo "dpkg -l | grep libcuda1 | awk '{print \$2}' >> nv.txt"
echo "dpkg -l | grep bbswitch | awk '{print \$2}' >> nv.txt"
echo "dpkg -l | grep libxnvctrl | awk '{print \$2}' >> nv.txt"
echo "if grep . nv.txt;then"
echo "sudo dpkg -P \$(cat nv.txt | tr '\\n' ' ')"
echo "fi"
#usuwanie starych źródeł
echo "for i in /var/lib/dkms/*/[^k]/source; do [ -e \$i ] || rm -rf $i;done"
}

nvidia(){
echo "echo \"$TEXT_PROCEDURA_15\""
echo "dpkg -l | grep ocl-icd-libopencl1 | awk '{print \$2}' > nv.txt"
echo "if grep . nv.txt;then"
echo "sudo dpkg -P \$(cat nv.txt | tr '\\n' ' ')"
echo "fi"
echo "if [ \"\$(apt-cache search libgcc | awk '{print \$1}' | grep -x lib32gcc1)\" = 'lib32gcc1' ]; then"
echo "sudo apt -f install ocl-icd-libopencl1 ocl-icd-libopencl1:i386 lib32gcc1 libvdpau1 libpango-1.0-0 x11-common make sed dkms linux-libc-dev libc6-dev patch acpid libc6-i386 passwd adduser pkg-config screen-resolution-extra libatk1.0-0 libc6 libcairo-gobject2 libcairo2 libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libgtk2.0-0 libjansson4  libpangocairo-1.0-0 libpangoft2-1.0-0 libx11-6 libxnvctrl0 libxxf86vm1 -y"
echo "else"
echo "sudo apt -f install ocl-icd-libopencl1 ocl-icd-libopencl1:i386 lib32gcc1-s1 libvdpau1 libpango-1.0-0 x11-common make sed dkms linux-libc-dev libc6-dev patch acpid libc6-i386 passwd adduser pkg-config screen-resolution-extra libatk1.0-0 libc6 libcairo-gobject2 libcairo2 libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libgtk2.0-0 libjansson4  libpangocairo-1.0-0 libpangoft2-1.0-0 libx11-6 libxnvctrl0 libxxf86vm1 -y"
echo "fi"
echo "sudo apt -f install libdrm-common pkg-config screen-resolution-extra -y"
echo "sudo apt -f install libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libgl1:i386 libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libpciaccess0:i386 libsensors5:i386 libx11-6:i386 libxcb-dri2-0:i386 libxcb-glx0:i386 libxcb-xfixes0:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i386 libxxf86vm1:i386 -y"
echo "sudo apt --fix-broken install"
echo "/usr/bin/yes | sudo dpkg -i *.deb"
echo "cd /tmp/netext73"
echo "rm -f *.tar.xz"
echo "rm -rf /tmp/nvidia"
echo "if [ \"\$(grep '#GRUB_GFXMODE' /etc/default/grub)\" != \"\" ]; then"
echo "sudo sed -i 's/#GRUB_GFXMODE.*/GRUB_GFXMODE=1024x768/' /etc/default/grub"
echo "fi"
echo "if [ \"\$(grep 'GRUB_GFXPAYLOAD_LINUX' /etc/default/grub)\" = \"\" ]; then"
echo "sudo sed -i \"s/GRUB_GFXMODE.*/GRUB_GFXMODE=1280x1024\nGRUB_GFXPAYLOAD_LINUX=1024x768/\" /etc/default/grub"
echo "fi"
echo "if [ -e /etc/X11/xorg.conf.\$(date +\"%m%d%Y\") ]; then"
echo "sudo mv /etc/X11/xorg.conf.\$(date +\"%m%d%Y\") /etc/X11/xorg.conf"
echo "fi"
#nogpumanager
echo "sudo sed -i 's/nogpumanager//g' /etc/default/grub"
#echo "sudo update-initramfs -u -k  $(uname -a | awk '{print $3}')"
echo "sudo update-grub"
}

nvidia_prime(){
echo "echo \"$TEXT_PROCEDURA_15 PRIME\""
#usunięcie nv i bumblebee
echo "sudo rm -f /etc/modprobe.d/nvidia.conf"
echo "sudo rm -f /etc/modprobe.d/bumblebee.conf"
#USUNIĘCIE MESY
echo "if [ \"\$(find /etc/apt/ | grep oibaf)\" != '' ]; then sudo ppa-purge ppa:oibaf/graphics-drivers; fi"
echo "if [ \"\$(find /etc/apt/ | grep x-swat)\" != '' ]; then sudo ppa-purge ppa:ubuntu-x-swat/updates; fi"
echo "if [ \"\$(find /etc/apt/ | grep paulo-miguel-dias)\" != '' ]; then sudo ppa-purge ppa:paulo-miguel-dias/mesa; fi"
echo "if [ \"\$(find /etc/apt/ | grep paulo-miguel-dias)\" != '' ]; then sudo ppa-purge ppa:paulo-miguel-dias/pkppa; fi"
echo "if [ \"\$(find /etc/apt/ | grep mesa-netext73)\" != '' ]; then sudo ppa-purge ppa:netext/mesa-netext73; fi"
echo "if [ \"\$(find /etc/apt/ | grep mesa-optimus-netext73)\" != '' ]; then sudo ppa-purge ppa:netext/mesa-optimus-netext73; fi"
#instalacja mesy haswell jak jest procesor powyżej haswella
echo "if [ -e /etc/netext73/haswelek ] && [ \"\$(grep TRUE /etc/netext73/haswelek)\" != '' ];then"
echo "sudo add-apt-repository ppa:netext/mesa-haswell-standard -y"
echo "elif [ \"\$(grep TRUE /etc/netext73/ryzenek)\" != '' ];then"
echo "sudo add-apt-repository ppa:netext/mesa-ryzen-standard -y"
echo "else"
#instalacja mesy standard jak nie ma haswella
echo "sudo add-apt-repository ppa:netext/mesa-optimus-netext73 -y"
echo "fi"
echo "sudo apt update"
echo "sudo apt -f install vainfo libvulkan1 libvulkan1:i386 vulkan-tools mesa-vulkan-drivers -y"
echo "if [ \"\$(apt-cache search libgcc | awk '{print \$1}' | grep -x lib32gcc1)\" = 'lib32gcc1' ]; then"
echo "sudo apt -f install ocl-icd-libopencl1 ocl-icd-libopencl1:i386 lib32gcc1 libvdpau1 libpango-1.0-0 x11-common make sed dkms linux-libc-dev libc6-dev patch acpid libc6-i386 passwd adduser pkg-config screen-resolution-extra libatk1.0-0 libc6 libcairo-gobject2 libcairo2 libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libgtk2.0-0 libjansson4  libpangocairo-1.0-0 libpangoft2-1.0-0 libx11-6 libxnvctrl0 libxxf86vm1 -y"
echo "else"
echo "sudo apt -f install ocl-icd-libopencl1 ocl-icd-libopencl1:i386 lib32gcc1-s1 libvdpau1 libpango-1.0-0 x11-common make sed dkms linux-libc-dev libc6-dev patch acpid libc6-i386 passwd adduser pkg-config screen-resolution-extra libatk1.0-0 libc6 libcairo-gobject2 libcairo2 libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libgtk2.0-0 libjansson4  libpangocairo-1.0-0 libpangoft2-1.0-0 libx11-6 libxnvctrl0 libxxf86vm1 -y"
echo "fi"
echo "sudo apt -f install libdrm-common pkg-config screen-resolution-extra -y"
echo "sudo apt -f install python3-gi python3-gi-cairo gir1.2-appindicator3-0.1 -y"
echo "sudo apt -f install libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libgl1:i386 libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libpciaccess0:i386 libsensors5:i386 libx11-6:i386 libxcb-dri2-0:i386 libxcb-glx0:i386 libxcb-xfixes0:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i386 libxxf86vm1:i386 -y"
echo "sudo apt --fix-broken install"
echo "if [ \"\$(dpkg -l | grep kubuntu-desktop)\" != '' ];then"
echo "sudo apt -f install python3-pyqt5 -y"
echo "fi"
echo "sudo apt dist-upgrade -y"
echo "/usr/bin/yes | sudo dpkg -i *.deb"
#usunięcie xorg wspieranych wersji
echo "if [ -e /etc/X11/xorg.conf ]; then"
echo "sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf_backup -f"
echo "fi"
#porządek z xorg
echo "sudo mkdir -p /etc/X11/xorg.conf.d/old/"
echo "if [ \"\$(ls /etc/X11/xorg.conf.d/ | grep xorg)\" != '' ]; then"
echo "sudo cp -fr /etc/X11/xorg.conf.d/xorg* /etc/X11/xorg.conf.d/old/"
echo "sudo rm -f /etc/X11/xorg.conf.d/xorg*"
echo "fi"
echo "cd /tmp/netext73/" #instalacja nvidia-prime
echo "/usr/bin/yes | ls /tmp/netext73/ | grep nvidia-prime | xargs sudo dpkg -i"
echo "cp -fr /tmp/prime-indicator-ext73-mod/usr/lib/* /usr/lib/"
echo "cp -fr /tmp/prime-indicator-ext73-mod/etc/X11/xorg.conf.d/* /etc/X11/xorg.conf.d/"
echo "cp -fr /tmp/prime-indicator-ext73-mod/etc/sudoers.d/* /etc/sudoers.d/"
echo "cp -fr /tmp/prime-indicator-ext73-mod/etc/xdg/autostart/* /etc/xdg/autostart/"
echo "rm  -f /etc/X11/xorg.conf.d/20-intel.conf" #usunięcie jak był 20-intel
echo "if [ \$jezyk='polski' ]; then" #zmiana języka indykatora
echo "if [ \"\$komputerek\" = 'INTEL' ];then"
echo "cp -f /usr/lib/prime-indicator/prime-indicator-pl /usr/lib/prime-indicator/prime-indicator"
echo "elif [ \"\$komputerek\" = 'AMD' ];then"
echo "cp -f /usr/lib/prime-indicator/prime-indicator-pl-amd /usr/lib/prime-indicator/prime-indicator"
echo "fi"
echo "else"
echo "if [ \"\$komputerek\" = 'INTEL' ];then"
echo "cp -f /usr/lib/prime-indicator/prime-indicator-eng /usr/lib/prime-indicator/prime-indicator"
echo "elif [ \"\$komputerek\" = 'AMD' ];then"
echo "cp -f /usr/lib/prime-indicator/prime-indicator-eng-amd /usr/lib/prime-indicator/prime-indicator"
echo "fi"
echo "fi"
echo "sudo chmod a+x /usr/lib/prime-indicator/prime-indicator"
echo "sudo chmod a+x /usr/lib/prime-indicator/gpuswitcher"
echo "if [ \"\$(prime-select query | grep -i intel)\" = '' ]; then" #przełączanie prime na intela
echo "prime-select intel && prime-select query"
echo "fi"
echo "export wersja_sterownika=\"\$(ls /tmp/netext73 | grep nvidia-graphics-driver | grep tar.xz | cut -d '-' -f 4 | head -n 1)\""
#szyna nv
#echo "lspci | egrep 'VGA|3D' | grep -i 'nvidia' | awk '{print \$1}' > /etc/netext73/szyna_nv"
#echo "sudo sed -i \"/BusID/ s/PCI:..:..:./PCI:$(cat /etc/netext73/szyna_nv)/g\" /etc/X11/xorg.conf.d/10-nvidia.conf_"
#echo "sudo sed -i '/BusID/ s/\./:/g' /etc/X11/xorg.conf.d/10-nvidia.conf_"
echo "sudo ldconfig"
#kasowanie źródła na końcu
echo "sudo rm -rf /tmp/prime-indicator-ext73-mod/"
echo "cd /tmp/netext73"
echo "rm -f *.tar.xz"
echo "rm -rf /tmp/nvidia"
echo "if [ \"\$(grep '#GRUB_GFXMODE' /etc/default/grub)\" != \"\" ]; then"
echo "sudo sed -i 's/#GRUB_GFXMODE.*/GRUB_GFXMODE=1024x768/' /etc/default/grub"
echo "fi"
echo "if [ \"\$(grep 'GRUB_GFXPAYLOAD_LINUX' /etc/default/grub)\" = \"\" ]; then"
echo "sudo sed -i \"s/GRUB_GFXMODE.*/GRUB_GFXMODE=1280x1024\nGRUB_GFXPAYLOAD_LINUX=1024x768/\" /etc/default/grub"
echo "fi"
echo "if [ -e /etc/X11/xorg.conf.\$(date +\"%m%d%Y\") ]; then"
echo "sudo mv /etc/X11/xorg.conf.\$(date +\"%m%d%Y\") /etc/X11/xorg.conf"
echo "fi"
#modyfikacja wpisów GRUB
#wpis nvidia-drm.modeset=1 usunąć
echo "if [ \"\$(grep nvidia-drm.modeset=1 /etc/default/grub)\" != '' ] ;then"
echo "sudo sed -i '/GRUB_CMDLINE_LINUX=/ s/nvidia-drm.modeset=1//' /etc/default/grub"
echo "fi"
#nogpumanager
echo "sudo sed -i 's/nogpumanager//g' /etc/default/grub"
#echo "sudo update-initramfs -u -k  $(uname -a | awk '{print $3}')"
echo "sudo update-grub"
#optimus service
echo "if [ -e /etc/netext73/nastawy_apm ];then"
echo "cp -f /opt/NeteXt73/APM/apm_ext73_optimus.service /etc/systemd/system/"
echo "systemctl stop apm_ext73_optimus.service"
echo "systemctl disable apm_ext73_optimus.service"
echo "fi"
}

nvidia_settings(){
echo "wersja_ster=\"\$(cat /tmp/wersja_sterownika.txt)\""
echo "echo \"\$wersja_ster\""
echo "if [ \"\$wersja_ster\" = '495' ];then"
echo "tar -Jxf /opt/NeteXt73/pakiety/nvidia-settings-495.tar.xz -C /tmp/"
echo "cp -f /tmp/libnvidia-gtk2.so.495.46 /usr/lib/"
echo "cp -f /tmp/libnvidia-gtk3.so.495.46 /usr/lib/"
echo "cp -f /tmp/nvidia-settings	/usr/bin/"
echo "rm -f /tmp/nvidia-settings /tmp/libnvidia-gtk3.so.495.46 /tmp/libnvidia-gtk2.so.495.46"
echo "elif [ \"\$wersja_ster\" = '510' ];then"
echo "tar -Jxf /opt/NeteXt73/pakiety/nvidia-settings-510.tar.xz -C /tmp/"
echo "cp -f /tmp/libnvidia-gtk2.so.510.47.03 /usr/lib/"
echo "cp -f /tmp/libnvidia-gtk3.so.510.47.03 /usr/lib/"
echo "cp -f /tmp/nvidia-settings	/usr/bin/"
echo "rm -f /tmp/nvidia-settings /tmp/libnvidia-gtk3.so.510.47.03 /tmp/libnvidia-gtk2.so.510.47.03"
echo "fi"
echo "rm -f /tmp/wersja_sterownika.txt"
#naprawa nv
echo "cp -fr /lib/x86_64-linux-gnu/nvidia/* /lib/nvidia/"
echo "cp -fr /lib/x86_64-linux-gnu/nvidia/* /usr/lib/nvidia/"
echo "ldconfig"
}

restart(){
if [ "$1" = "kernel" ]; then
	yad --center --on-top --question --title="$nazwa_skryptu" --window-icon="/opt/NeteXt73/ikony/pytanie.png" --image="/opt/NeteXt73/ikony/pytanie.png" --button="$TEXT_TAK:0" --button="$TEXT_NIE:1" --text="$TEXT_KERNEL2\n\n$TEXT_RESTART"
elif [ "$1" = "nv" ]; then
	yad --center --on-top --question --title="$nazwa_skryptu" --window-icon="/opt/NeteXt73/ikony/pytanie.png" --image="/opt/NeteXt73/ikony/pytanie.png" --button="$TEXT_TAK:0" --button="$TEXT_NIE:1" --text="$TEXT_NVIDIA2\n\n$TEXT_RESTART"
elif [ "$1" = "mesa" ]; then
	yad --center --on-top --question --title="$nazwa_skryptu" --window-icon="/opt/NeteXt73/ikony/pytanie.png" --image="/opt/NeteXt73/ikony/pytanie.png" --button="$TEXT_TAK:0" --button="$TEXT_NIE:1" --text="$TEXT_MESA2\n\n$TEXT_RESTART"
else
	yad --center --on-top --question --title="$nazwa_skryptu" --window-icon="/opt/NeteXt73/ikony/pytanie.png" --image="/opt/NeteXt73/ikony/pytanie.png" --button="$TEXT_TAK:0" --button="$TEXT_NIE:1" --text="$TEXT_RESTART"
fi
if [ $? = 0 ]; then
	reboot
fi
}

sprawdz_klucze(){
#xterm -T GPG-KEY -e bash -c "echo 'sudo apt-key list'";
sudo apt-key list > klucze1.txt
}
usun_klucze(){
xterm -T GPG-KEY -e bash -c "echo 'Usuwanie zaznaczonych kluczy'; for i in \$(cat usun.txt); do sudo apt-key del \$i; done ; echo 'sudo apt-key list' ; sudo apt-key list > klucze1.txt"
}


klucze(){
echo "sudo apt update 2> /tmp/netext73/updateresults"
echo "MISSINGKEYS=\$(cat /tmp/netext73/updateresults | grep GPG | sed -e 's/.*NO_PUBKEY//g')"
echo "if [[ \$MISSINGKEYS ]]; then"
echo "echo 'Trying to import all the missing keys'"
echo "for GPGKEYTOGET in \$(cat /tmp/netext73/updateresults | grep GPG | sed -e 's/.*NO_PUBKEY //g'); do"
echo "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys \$GPGKEYTOGET"
echo "done"
echo "sudo cp -f /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/"
echo "sudo apt update"
echo "fi"
}

napraw_klucze(){
echo "echo -e \"$TEXT_NAPRAW_GPG\\n\"; sudo apt clean; sudo mv /var/lib/apt/lists /tmp/netext73; sudo mkdir /var/lib/apt/lists; sudo apt update; sudo rm -rf /tmp/netext73/lists"
}

stan_baterii(){
info_o_baterii=$(cat /sys/class/power_supply/BAT*/uevent )
Stan_baterii="Battery status"; licznik=1

for a in "POWER_SUPPLY_NAME" "POWER_SUPPLY_STATUS" "POWER_SUPPLY_TECHNOLOGY" "POWER_SUPPLY_MODEL_NAME" "POWER_SUPPLY_MANUFACTURER" "POWER_SUPPLY_SERIAL_NUMBER" "POWER_SUPPLY_VOLTAGE_MIN_DESIGN" "POWER_SUPPLY_VOLTAGE_NOW" "POWER_SUPPLY_CAPACITY"; do
	if [ "$(grep pol /etc/netext73/jezyk)" = "" ]; then
		bar[$licznik]="$(echo $info_o_baterii | tr ' ' '\n' | grep $a | cut -d '=' -f 1)"
		bar[10]="POWER_SUPPLY_FULL_CAPACITY"
	fi
	stan[$licznik]="$(echo $info_o_baterii | tr ' ' '\n' | grep $a | cut -d '=' -f 2)"
	((licznik++))
done

#pojemność
if [ "$(echo $info_o_baterii | grep POWER_SUPPLY_CHARGE_FULL_DESIGN)" != "" ]; then
	bateria_full="$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_CHARGE_FULL= | cut -d '=' -f 2)/1000" | bc -q)"
	bateria_teraz="$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_CHARGE_NOW= | cut -d '=' -f 2)/1000" | bc -q)"
	jednostka="mAh"
else
	bateria_full="$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_ENERGY_FULL= | cut -d '=' -f 2)/1000000" | bc -q)"
	bateria_teraz="$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_ENERGY_NOW= | cut -d '=' -f 2)/1000000" | bc -q)"
	jednostka="Wh"
fi
#zmiana języka
#jezyczek
if [ "$(grep pol /etc/netext73/jezyk)" != "" ]; then
	Stan_baterii="Stan baterii"
	bar[1]="Nazwa baterii"
	bar[2]="Tryb pracy baterii"
	bar[3]="Rodzaj baterii"
	bar[4]="Model baterii"
	bar[5]="Producent baterii"
	bar[6]="Nr seryjny baterii"
	bar[7]="Konstrukcyjne napięcie baterii"
	bar[8]="Aktualne napięcie baterii"
	bar[9]="Aktualna pojemność baterii"
	bar[10]="Maksymalny poziom naładowania baterii"
	if [ "$(echo ${stan[2]})" = "Discharging" ];then
		stan[2]="Rozładowywanie"
	elif [ "$(echo ${stan[2]})" = "Charging" ];then
		stan[2]="Ładowywanie"
	elif [ "$(echo ${stan[2]})" = "Full" ];then
		stan[2]="Pełna"
	else
		stan[2]="Nieznany"
	fi
	if [ "$(echo ${stan[3]})" = "Unknown" ];then
		stan[3]="Nieznany"
	fi
fi
#przeliczanie napięcia na V
stan[7]=$(echo "scale=2; ${stan[7]}/1000000" | bc -q)
stan[8]=$(echo "scale=2; ${stan[8]}/1000000" | bc -q)

if [ "$(echo $info_o_baterii | grep POWER_SUPPLY_ENERGY_FULL_DESIGN)" != "" ]; then
	poj_produkcyjna=$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_ENERGY_FULL_DESIGN= | cut -d '=' -f 2)/10000" | bc -q)
	poj_teraz=$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_ENERGY_FULL= | cut -d '=' -f 2)/10000" | bc -q)
	if [ "$poj_produkcyjna" != "0" ] || [ "$poj_produkcyjna" != "" ]; then
		stan[10]=$(echo "scale=0; 100*$poj_teraz/$poj_produkcyjna" | bc -q)
		stan[9]=$(echo "scale=0; 100*$bateria_teraz/$bateria_full" | bc -q)
	else
		stan[10]=0
		stan[9]=0
	fi
else
	poj_produkcyjna=$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_CHARGE_FULL_DESIGN= | cut -d '=' -f 2)/10000" | bc -q)
	poj_teraz=$(echo "scale=0; $(echo $info_o_baterii | tr ' ' '\n' | grep POWER_SUPPLY_CHARGE_FULL= | cut -d '=' -f 2)/10000" | bc -q)
	if [ "$poj_produkcyjna" != "0" ] || [ "$poj_produkcyjna" != "" ]; then
		stan[10]=$(echo "scale=0; 100*$poj_teraz/$poj_produkcyjna" | bc -q)
		stan[9]=$(echo "scale=0; 100*$bateria_teraz/$bateria_full" | bc -q)
	else
		stan[10]=0
		stan[9]=0
	fi
fi
for i in $(seq 1 2); do
	for a in $(seq 1 $(($licznik-3))); do
		echo "$a:#${stan[$a]}"
	done

	echo "7:#${stan[7]} V"; echo "7:${stan[7]}" # V baterii
	echo "8:#${stan[8]} V"; echo "8:${stan[8]}" # V baterii
	echo "9:#${stan[9]} %      $bateria_teraz $jednostka"; echo "9:${stan[9]}" # % baterii
	echo "10:#${stan[10]} %        $bateria_full $jednostka"; echo "10:${stan[10]}" # % baterii
	sleep 5
done | yad --center --on-top --multi-progress  --title=" $nazwa_skryptu" --bar="$(echo ${bar[1]})" --bar="$(echo ${bar[2]})" --bar="$(echo ${bar[3]})" --bar="$(echo ${bar[4]})" --bar="$(echo ${bar[5]})" --bar="$(echo ${bar[6]})" --bar="$(echo ${bar[7]})" --bar="$(echo ${bar[8]})" --bar="$(echo ${bar[9]})"  --bar="$(echo ${bar[10]})" --auto-kill --window-icon="/opt/NeteXt73/ikony/apm.png" --image="/opt/NeteXt73/ikony/apm.png" --text="$Stan_baterii:\n" --button="$TEXT_ZAMKNIJ:1"
}

ipv6_off(){
echo "sudo apt autoremove miredo -y && dpkg -l | awk '/^rc/{ print \$2}' | sudo xargs dpkg --purge"
echo "echo \"#disable ipv6\" | sudo tee -a /etc/sysctl.conf"
echo "echo \"net.ipv6.conf.all.disable_ipv6 = 1\" | sudo tee -a /etc/sysctl.conf"
echo "echo \"net.ipv6.conf.default.disable_ipv6 = 1\" | sudo tee -a /etc/sysctl.conf"
echo "echo \"net.ipv6.conf.lo.disable_ipv6 = 1\" | sudo tee -a /etc/sysctl.conf"
echo "sudo sysctl -p"
}

ipv6_on(){
echo "sudo apt install miredo -y"
echo "sudo sed -i '/#disable ipv6/d' /etc/sysctl.conf"
echo "sudo sed -i '/net.ipv6.conf.all.disable_ipv6 = 1/d' /etc/sysctl.conf"
echo "sudo sed -i '/net.ipv6.conf.default.disable_ipv6 = 1/d' /etc/sysctl.conf"
echo "sudo sed -i '/net.ipv6.conf.lo.disable_ipv6 = 1/d' /etc/sysctl.conf"
echo "sudo sysctl -p"
}


upstart_test(){
rm *.txt -f
sudo initctl list | grep -v -E "cryptdisks-udev|network-interface|network-interface-security|wait-for-state" > lista.txt
}


burntest(){
xterm -T "glxgears" -e bash -c "glxgears" &
for i in $(seq 1 $(grep 'model name' /proc/cpuinfo | wc -l )); do
xterm -T "BurnTest $i" -e bash -c "echo'';echo'';echo '███╗   ██╗███████╗████████╗███████╗██╗  ██╗████████╗███████╗██████╗ ';echo '████╗  ██║██╔════╝╚══██╔══╝██╔════╝╚██╗██╔╝╚══██╔══╝╚════██║╚════██╗';echo '██╔██╗ ██║█████╗     ██║   █████╗   ╚███╔╝    ██║       ██╔╝ █████╔╝';echo '██║╚██╗██║██╔══╝     ██║   ██╔══╝   ██╔██╗    ██║      ██╔╝  ╚═══██╗';echo '██║ ╚████║███████╗   ██║   ███████╗██╔╝ ██╗   ██║      ██║  ██████╔╝';echo '╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚══════╝╚═╝  ╚═╝   ╚═╝      ╚═╝  ╚═════╝ ';echo'';echo'';echo '███╗   ██╗███████╗████████╗███████╗██╗  ██╗████████╗███████╗██████╗ ';echo '████╗  ██║██╔════╝╚══██╔══╝██╔════╝╚██╗██╔╝╚══██╔══╝╚════██║╚════██╗';echo '██╔██╗ ██║█████╗     ██║   █████╗   ╚███╔╝    ██║       ██╔╝ █████╔╝';echo '██║╚██╗██║██╔══╝     ██║   ██╔══╝   ██╔██╗    ██║      ██╔╝  ╚═══██╗';echo '██║ ╚████║███████╗   ██║   ███████╗██╔╝ ██╗   ██║      ██║  ██████╔╝';echo '╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚══════╝╚═╝  ╚═╝   ╚═╝      ╚═╝  ╚═════╝ ';echo'';echo'';echo '███╗   ██╗███████╗████████╗███████╗██╗  ██╗████████╗███████╗██████╗ ';echo '████╗  ██║██╔════╝╚══██╔══╝██╔════╝╚██╗██╔╝╚══██╔══╝╚════██║╚════██╗';echo '██╔██╗ ██║█████╗     ██║   █████╗   ╚███╔╝    ██║       ██╔╝ █████╔╝';echo '██║╚██╗██║██╔══╝     ██║   ██╔══╝   ██╔██╗    ██║      ██╔╝  ╚═══██╗';echo '██║ ╚████║███████╗   ██║   ███████╗██╔╝ ██╗   ██║      ██║  ██████╔╝';echo '╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚══════╝╚═╝  ╚═╝   ╚═╝      ╚═╝  ╚═════╝ ';python3 -c \"while True: pass\"" &
done
xterm -T "htop" -e bash -c "htop"
}

yad_wget(){

# NAME:         yad_wget
# VERSION:      0.2
# AUTHOR:       (c) 2014 Glutanimate
# DESCRIPTION:  graphical frontend to wget in form of a yad script
# FEATURES:     - display progress of multiple simultaneous downloads
#               - set maximum number of simultaneous downloads
# DEPENDENCIES: yad
#
#
# LICENSE:      GNU GPLv3 (http://www.gnu.de/documents/gpl-3.0.en.html)
#
# NOTICE:       THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
#               EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
#               PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
#               IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
#               AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
#               PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
#               YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
#
#               IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
#               COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
#               PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
#               INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
#               THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
#               INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
#               PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
#               PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
# USAGE:        yad_wget <space-delimited URLs>
#               Closing the yad dialog will terminate all downloads in progress

# Variables and settings

MAXDLS="5" # set maximum number of simultaneous downloads

URILIST="$@" # gets list of URIs from stdin
USAGE="$0 <space-delimited URLs>"

# Usage checks

if [[ -z "$URILIST" ]];then
	echo "Error: No arguments provided"
	echo "Usage: $USAGE"
	exit 1
fi

download(){
if [ "$(echo $1 | grep premium)" != "" ]; then  #jeżeli konto premium to logujemy się na hasło
	wget --http-user=$US1 --http-password=$PASS1 "$1" 2>&1 | sed -u \
	"s/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/$2:\1\n$2:#  \2\/s,  \3/"
	RET_WGET="${PIPESTATUS[0]}"             # get return code of wget
	if [[ "$RET_WGET" = 0 ]]                # check return code for errors
	then
		echo "$2:100%"
		echo "$2:#$TEXT_POBIERANIE_GOTOWE"
	else
		echo "$2:#$TEXT_BLAD_POBIERANIA"
	fi
	else
	wget  "$1" 2>&1 | sed -u \
	"s/.* \([0-9]\+%\)\ \+\([0-9,.]\+.\) \(.*\)/$2:\1\n$2:#  \2\/s,  \3/"
	RET_WGET="${PIPESTATUS[0]}"             # get return code of wget
	if [[ "$RET_WGET" = 0 ]]                # check return code for errors
	then
		echo "$2:100%"
		echo "$2:#$TEXT_POBIERANIE_GOTOWE"
	else
		echo "$2:#$TEXT_BLAD_POBIERANIA"
	fi
fi
}

# compose list of bars for yad
for URI in $URILIST; do                     # iterate through all URIs
	FILENAME="${URI##*/}"                   # extract last field of URI as filename
	YADBARS="$YADBARS --bar=$(echo $FILENAME | sed "s/1.txt/$TEXT_SUMY_KONTROLNE/"):NORM" # add filename to the list of URIs
done

IFS=" "
COUNTER="1"
DYNAMIC_COUNTER="1"

# main
# iterate through all URIs, download them in the background and
# pipe all output simultaneously to yad
# source: http://pastebin.com/yBL2wjaY

for URI in $URILIST; do
	if [[ "$DYNAMIC_COUNTER" = "$MAXDLS" ]] # only download n files at a time
	then
		 download "$URI" "$COUNTER"        # if limit reached wait until wget complete
		  DYNAMIC_COUNTER="1"               # before proceeding (by not sending download() to bg)
	else
		  download "$URI" "$COUNTER" &      # pass URI and URI number to download()
		  DYNAMIC_COUNTER="$[$DYNAMIC_COUNTER+1]"
	fi
	COUNTER="$[$COUNTER+1]"                 # increment counter
done | yad --center --on-top --multi-progress --auto-kill --auto-close --width=$((700*$skala)) $YADBARS --title "$nazwa_skryptu" \
--text "<b>$TEXT_POB2</b>" --window-icon="/opt/NeteXt73/ikony/download.png" --image="/opt/NeteXt73/ikony/download.png" --button="$TEXT_ZAMKNIJ:1"
# ↑ launch yad multi progress-bar window
}

procesor_monitor(){
barek="--bar="" --bar="$(free -m | awk '{print $1}' | head -n 1)" --bar="$(free -m | awk '{print $2}' | head -n 1)" --bar="$(free -m | awk '{print $3}' | head -n 1)" --bar="$(free -m | awk '{print $4}' | head -n 1)" --bar="$(free -m | awk '{print $5}' | head -n 1)" --bar="$(free -m | awk '{print $6}' | head -n 1)" --bar=swap --bar="""
for i in $(seq 1 $(grep 'model name' /proc/cpuinfo | wc -l )); do
	barek="$barek --bar=$(echo "core"$i"")"
done
petla_duza="tak"
if [ -e /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq ]; then
	cpu_max=$(( $(cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq | head -n 1) / 100000 ))
else
	cpu_max=$(( 5500000 / 100000 ))
fi
while [ "$petla_duza" = "tak" ]; do
	echo "2:$((100*$(free -m | sed -n 2p | awk '{print $2}')/$(free -m | sed -n 2p | awk '{print $2}')))"
	echo "3:$((100*$(free -m | sed -n 2p | awk '{print $3}')/$(free -m | sed -n 2p | awk '{print $2}')))"
	echo "4:$((100*$(free -m | sed -n 2p | awk '{print $4}')/$(free -m | sed -n 2p | awk '{print $2}')))"
	echo "5:$((100*$(free -m | sed -n 2p | awk '{print $5}')/$(free -m | sed -n 2p | awk '{print $2}')))"
	echo "6:$((100*$(free -m | sed -n 2p | awk '{print $6}')/$(free -m | sed -n 2p | awk '{print $2}')))"
	echo "7:$((100*$(free -m | sed -n 2p | awk '{print $7}')/$(free -m | sed -n 2p | awk '{print $2}')))"
	echo "1:#M E M O R Y"
	echo "2:#$(free -m | sed -n 2p | awk '{print $2}') MB"
	echo "3:#$(free -m | sed -n 2p | awk '{print $3}') MB"
	echo "4:#$(free -m | sed -n 2p | awk '{print $4}') MB"
	echo "5:#$(free -m | sed -n 2p | awk '{print $5}') MB"
	echo "6:#$(free -m | sed -n 2p | awk '{print $6}') MB"
	echo "7:#$(free -m | sed -n 2p | awk '{print $7}') MB"
	if [ "$(free -m | tail -n 1 | awk '{print $4}')" = "" ] || [ "$(free -m | tail -n 1 | awk '{print $4}')" = "0" ]; then
		echo "8:0"
		echo "8:#0 MB"
	else
		echo "8:$((100*$(free -m  |  tail -n 1 | awk '{print $3}')/$(free -m | tail -n 1 | awk '{print $2}')))"
		echo "8:#$(free -m |  tail -n 1 | awk '{print $3}') /  $(free -m | tail -n 1 | awk '{print $2}') MB"
	fi
	echo "9:#C P U      C O R E     F R E Q U E N C Y"

	for i in $(seq 10 $(($(grep 'model name' /proc/cpuinfo | wc -l )+9))); do
		if [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ];then
			czestotliwosc=$(($(cat /sys/devices/system/cpu/cpu$(($i-10))/cpufreq/scaling_cur_freq)/1000))
		else
			czestotliwosc=$(($(grep MHz /proc/cpuinfo | cut -d ':' -f 2 | sed 's/\.//' | head -n $(($i-9)) | tail -n 1)/1000))
		fi
		echo "$i:$(($czestotliwosc/$cpu_max))" # * 6000MHZ/100
		echo "$i:#$czestotliwosc MHz"
		#echo "$i:$(($(cat /proc/cpuinfo | grep MHz | cut -d ' ' -f 3 | sed -n $(($i-9))'p' | sed 's/\..*//' )/$cpu_max))" # * 6000MHZ/100
		#echo "$i:#$(cat /proc/cpuinfo | grep MHz | cut -d ' ' -f 3 | sed -n $(($i-9))'p' | sed 's/\..*//' ) MHz"
	done
	sleep 5
done | yad --title "$nazwa_skryptu" --center --multi-progress $barek --text="$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | sed 's/.*: //')\n\n" --auto-kill --on-top --window-icon="/opt/NeteXt73/ikony/monitor.png" --image="/opt/NeteXt73/ikony/monitor.png" --width=$((460*$skala)) --button="$TEXT_ZAMKNIJ:1"
if [ "$?" != "" ]; then
	petla_duza="nie"
fi
}

hdd_stan(){
a=1
for i in $(echo $lista_dyskow); do
	for b in $(df -h | grep /dev/$i | awk '{print $1}' | sort);do
		barek="$barek --bar=$(echo "$b")"
		dysk[$a]="$b"
		a=$(( $a + 1 ))
	done
done
petla_duza="tak"

while [ "$petla_duza" = "tak" ]; do
	for i in $(seq 1 $(df -h | awk '{print $1}' | grep /dev/ | wc -l)); do
#		echo "$(($i+$i-1)):#$(df -h | grep "${dysk[$i]}" | awk '{print $6}')"
		echo "$(($i)):$(df -h | grep "${dysk[$i]}" | awk '{print $5}')"
		echo "$(($i)):#$(df -h | grep "${dysk[$i]}" | awk '{print $6}')  $(df -h | grep "${dysk[$i]}" | awk '{print "used "$3" - "$5" / Size "$2}')"
	done
	sleep 5
done | yad --title "$nazwa_skryptu" --image=drive-harddisk --center --multi-progress $barek --text="HDD monitor" --auto-kill --on-top --width=$((660*$skala)) --button="$TEXT_ZAMKNIJ:1"
if [ "$?" != "" ]; then
	petla_duza="nie"
fi
}

opusc_petle(){
	petla_duza="nie"
	rm *.txt -f *.sh
}

opusc_mala_petle(){
	petla="nie"
	rm *.txt -f *.sh
}

kill_yad(){
	kill -9 $(ps -aux | grep yad | grep $1 | awk '{print $2}' | head -n 1)
}

instaluj_gcc(){
#export wersja_libgsl=$(ls -la  /usr/lib/x86_64-linux-gnu/ | grep libgsl.so | grep -e '-rw' | sed 's/.* //' | head -n 1)
export wersja_libisl=$(ls -la  /usr/lib/x86_64-linux-gnu/ | grep libisl.so | grep -e '-rw' | sed 's/.* //' | head -n 1)

if [ "$1" = "instaluj_nowy" ];then
	cat /opt/NeteXt73-binutils/install.sh | grep -v ^# | sed '/^[ \t]*$/ d'
	cat /opt/NeteXt73-gcc/install.sh | grep -v ^# | sed '/^[ \t]*$/ d'
elif [ "$1" = "zmien_stary" ];then
	echo "sudo rm -f /usr/bin/gcc"
	echo "sudo rm -f /usr/bin/gcc-ar"
	echo "sudo rm -f /usr/bin/cpp"
	echo "sudo rm -f /usr/bin/g++"
	echo "sudo rm -f /usr/bin/c++"
	echo "sudo ln -sf /usr/bin/gcc-\$wersja /usr/bin/gcc"
	echo "sudo ln -sf /usr/bin/gcc-ar-\$wersja /usr/bin/gcc-ar"
	echo "sudo ln -sf /usr/bin/cpp-\$wersja /usr/bin/cpp"
	echo "sudo ln -sf /usr/bin/g++-\$wersja /usr/bin/g++"
	echo "sudo ln -sf /usr/bin/g++ /usr/bin/c++"
	#reinstalacja gcc
	echo "sudo apt install $(dpkg -l | grep gcc- | grep 'compiler' | tail -n 1 | cut -d ' ' -f 3 | sed 's/)//') --reinstall -y"
	#reinstalacja libstdc
	echo "sudo apt install $(dpkg -l | grep libstdc | grep -v 'dev' | head -n 1 | cut -d ' ' -f 3) --reinstall -y"
	echo "sudo apt install binutils --reinstall -y"
	echo "sudo ldconfig"
	echo "\$(gcc -v)"
fi
}

sumy(){
#pobranie sum kontrolnych
pobieranie_listy_kerneli

cd /tmp
#Sumy kontrolne
openssl enc -d -aes-256-cbc -salt -pbkdf2 -in /tmp/netext73/sumy/sumy_256.txt -pass pass:sumykontrolne -out $sumy_kontrolne
rm sumy_kontrolne.txt -f
if [ "$(cat $sumy_kontrolne)" = "" ]; then
	yad --center --info --title="$nazwa_skryptu  " --text="<span color=\"$kolor_textu\"><b>$BRAKNETA</b></span>" --window-icon="/opt/NeteXt73/ikony/error.png" --image="/opt/NeteXt73/ikony/error.png" --button="gtk-ok:0" --on-top
	exit 1
fi
if [ "$(cat /opt/NeteXt73/changelog | grep -E v[0-9].\{1,2\}[0-9].\{1,2\}[0-9] | sed 's/v//g' | grep $(cat /tmp/netext73/sumy/wersja_netext73.txt))" = '' ]; then
	dymek -i $warning1 "$TEXT_UWAGA" "$TEXT_WERSJA_PROGRAMU"
fi
}

#ostrzeżenie o konfliktach
zaleznosci(){
cd /tmp/netext73
plik=""
if [ "$1" = "tlp" ]; then
	lista_zaleznosci="tlp"
else
	lista_zaleznosci="acpi-call laptop-mode-tools ulatelcy ulatencyd cpufrequtils ureadahead"
fi
for i in $(echo $lista_zaleznosci);do
	if [ "$i" = "ureadahead" ] && [ "$(systemctl --failed | grep ureadahead)" != "" ] && [ "$(dpkg -l | awk '{print $2}' | grep $i -x)" != "" ]; then
		export plik="$plik $i"
	elif  [ "$i" != "ureadahead" ] &&  [ "$(dpkg -l | awk '{print $2}' | grep $i -x)" != "" ];then
		export plik="$plik $i"
	fi
done

if [ "$plik" != "" ]; then
	if yad --center --question --on-top --title="$nazwa_skryptu" --window-icon="/opt/NeteXt73/ikony/pytanie.png" --image="/opt/NeteXt73/ikony/pytanie.png" --button="$TEXT_TAK:0" --button="$TEXT_POWROT:1" --text="$TEXT_WARRING_DEP1\n$plik"; then
		naglowek > instaluj.sh
		echo "sudo apt purge $plik" >> instaluj.sh
		instalacja
	fi
fi
#dymki dla KDE
if [ "$(dpkg -l | grep kubuntu)" != "" ] && [ "$(which kdialog)" = "" ]; then
	plik2="kdialog"
	naglowek > instaluj.sh
	echo "sudo apt install $plik2 -f" >> instaluj.sh
	instalacja depends
fi

#firmware-sof-signed dla intela
if [ "$(dpkg -l | grep firmware-sof-signed)" = "" ] && [ "$komputerek" = "INTEL" ]; then
	plik3="firmware-sof-signed"
	naglowek > instaluj.sh
	echo "sudo apt install $plik3 -f" >> instaluj.sh
	instalacja depends
fi


#naprawa Gtk-WARNING **: Theme file for default has no directories
if [ -e $domek/.gtkrc-2.0 ] && [ "$(grep gtk-fallback-icon-theme="default" $domek/.gtkrc-2.0)" != "" ]; then
	sed -i 's/gtk-fallback-icon-theme="default"/gtk-fallback-icon-theme="gnome"/' $domek/.gtkrc-2.0
fi

#życzenia świąteczne
DATA=$(date +"%m-%d")
if [ "$(echo $DATA | grep -o -E -x '12-2[4-6]')" != "" ]; then
	yad --center --info --title="$nazwa_skryptu   "  --text="\n\n\n\n\n\n\nZespół NeteXt'73 życzy\n<span color=\"$kolor_textu\"><b>Wesołych Świąt Bożego Narodzenia!</b></span>\n\n\nNeteXt'73 team\n<span color=\"$kolor_textu\"><b>wishes Merry Christmas!</b></span>" --window-icon="/opt/NeteXt73/ikony/tux_santa.png" --image="/opt/NeteXt73/ikony/tux_santa.png" --button="gtk-ok:0" --on-top
fi
#życzenia noworoczne
if [ "$DATA" = "12-31" ]; then
	yad --center --info --title="$nazwa_skryptu   "  --text="\n\n\n<span color=\"$kolor_textu\"><b>Happy New Year !!</b></span>\n\n\nNeteXt'73 team wishes Happy New Year $(( $(date +"%Y")+1 ))\n\nZespół NeteXt'73 życzy Szczęśliwego Nowego Roku $(( $(date +"%Y")+1 ))" --window-icon="/opt/NeteXt73/ikony/happyny.png" --image="/opt/NeteXt73/ikony/happyny.png" --button="gtk-ok:0" --on-top
fi
if [ "$DATA" = "01-01" ]; then
	yad --center --info --title="$nazwa_skryptu   "  --text="\n\n\n<span color=\"$kolor_textu\"><b>Happy New Year !!</b></span>\n\n\nNeteXt'73 team wishes Happy New Year $(( $(date +"%Y") ))\n\nZespół NeteXt'73 życzy Szczęśliwego Nowego Roku $(( $(date +"%Y") ))" --window-icon="/opt/NeteXt73/ikony/happyny.png" --image="/opt/NeteXt73/ikony/happyny.png" --button="gtk-ok:0" --on-top
fi
#dymki wyłączone
#if [ -e /etc/netext73/donate ] && [ "$(grep TRUE /etc/netext73/donate)" != '' ] || [ ! -e /etc/netext73/donate ]; then
	#domena pl
#	if [ "$(echo $DATA | grep -o -E -x '02-0[7-9]')" != "" ] || [ "$(echo $DATA | grep -o -E -x '02-1[0-9]')" != "" ]; then
#		yad --center --info --title="$nazwa_skryptu   "  --text="<span color='red'><b>$TEXT_HELP_NAM</b></span>\n<span color=\"$kolor_textu\"><b>$TEXT_DONATE_US1</b></span>\n\n" --window-icon="/opt/NeteXt73/ikony/tux_santa.png" --image="/opt/NeteXt73/ikony/donate.png" --button="gtk-ok:0" --on-top
#	fi
	#domena com
#	if [ "$(echo $DATA | grep -o -E -x '12-0[1-9]')" != "" ] || [ "$(echo $DATA | grep -o -E -x '12-1[0-4]')" != "" ]; then
#		yad --center --info --title="$nazwa_skryptu   "  --text="<span color='red'><b>$TEXT_HELP_NAM</b></span>\n<span color=\"$kolor_textu\"><b>$TEXT_DONATE_US2</b></span>\n\n" --window-icon="/opt/NeteXt73/ikony/tux_santa.png" --image="/opt/NeteXt73/ikony/donate.png" --button="gtk-ok:0" --on-top
#	fi
	#serwer vps
#	if [ "$(echo $DATA | grep -o -E -x '04-2[5-9]')" != "" ] || [ "$(echo $DATA | grep -o -E -x '04-30')" != "" ]  || [ "$(echo $DATA | grep -o -E -x '05-0[1-2]')" != "" ]; then
#		yad --center --info --title="$nazwa_skryptu   "  --text="<span color='red'><b>$TEXT_HELP_NAM</b></span>\n<span color=\"$kolor_textu\"><b>$TEXT_DONATE_US3</b></span>\n\n" --window-icon="/opt/NeteXt73/ikony/tux_santa.png" --image="/opt/NeteXt73/ikony/donate.png" --button="gtk-ok:0" --on-top
#	fi
#fi


}

pastebinit_netext73(){
curl -0 -d title="$1" -d private=1 -d name=$userek2 -d lang=bash -d expire=10080 --data-urlencode text@- $adres_logi
}

kill_process(){
petla="tak"
while [ $petla = "tak" ]; do
	process=$(ps -u $USER | yad --center --list --title="$nazwa_skryptu" --window-icon="process-stop" --image="process-stop" --column "$TEXT_SELECT_TO_KILL" --text="$TEXT_LISTA_PROCESOW $USER $TEXT_PROCESY" --width $((450*$skala)) --height $((450*$skala)) --button="gtk-ok:0" --button="$TEXT_ZAMKNIJ:1" --on-top )
	ans=$(echo $?)
	if test "$ans" -eq "0"; then
		select=$(echo $process | cut -d" " -f1)
		kill $select # 2> /dev/null
	fi

	if test "$ans" -eq "1"; then
		petla="nie"
	fi
done
}

proces_zablokowany(){
	#ostrzeżenie o aktywnym procesie instalacji
	yad --center --on-top --info --title="$TEXT_UWAGA"  --window-icon="$warning1" --image="$warning1" --text="$TEXT_UPDATE_ZAJETY" --timeout 5 --no-buttons
	#usuwanie plików tymczasowych poza sumami i nazwą usera
	find /tmp/netext73/* | grep -v -E "sumy|userek|userek2" | xargs rm -rf
	exit 0
}

linux_ext73_tools_install(){
	echo "tar -xJf /opt/NeteXt73/pakiety/linux-ext73-tools.tar.xz -C /tmp/netext73/"
	echo "cp -rf /tmp/netext73/linux-ext73-tools/etc/* /etc/"
	echo "cp -rf /tmp/netext73/linux-ext73-tools/bin /usr/"
	echo "cp -rf /tmp/netext73/linux-ext73-tools/lib /usr/"
	echo "cp -rf /tmp/netext73/linux-ext73-tools/lib64 /usr/"
	echo "cp -rf /tmp/netext73/linux-ext73-tools/libexec /usr/"
	echo "cp -rf /tmp/netext73/linux-ext73-tools/share /usr/"
	echo "rm -rf /tmp/netext73/linux-ext73-tools"
	echo "ldconfig"
}