This file is indexed.

/usr/share/doc/copyq/html/scripting-api.html is in copyq-doc 3.2.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1762
1763
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Scripting API &mdash; CopyQ  documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/icon_32x32.png"/>
  
  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  

  

  
        <link rel="index" title="Index"
              href="genindex.html"/>
        <link rel="search" title="Search" href="search.html"/>
    <link rel="top" title="CopyQ  documentation" href="index.html"/>
        <link rel="next" title="Build from Source Code" href="build-source-code.html"/>
        <link rel="prev" title="Writing Raw Data" href="writing-raw-data.html"/> 

  
  <script src="_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="index.html" class="icon icon-home"> CopyQ
          

          
            
            <img src="_static/icon_64x64.png" class="logo" />
          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">The Basics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="basic-usage.html">Basic Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="tabs-and-items.html">Tabs and Items</a></li>
<li class="toctree-l1"><a class="reference internal" href="keyboard.html">Keyboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="images.html">Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="tags.html">Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ - Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
</ul>
<p class="caption"><span class="caption-text">Advanced Topics</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="command-line.html">Command Line</a></li>
<li class="toctree-l1"><a class="reference internal" href="sessions.html">Sessions</a></li>
<li class="toctree-l1"><a class="reference internal" href="pin-items.html">Pin Items</a></li>
<li class="toctree-l1"><a class="reference internal" href="password-protection.html">Password Protection</a></li>
<li class="toctree-l1"><a class="reference internal" href="synchronize.html">Synchronize with Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="writing-commands-and-adding-functionality.html">Writing Commands and Adding Functionality</a></li>
<li class="toctree-l1"><a class="reference internal" href="scripting.html">Scripting</a></li>
<li class="toctree-l1"><a class="reference internal" href="command-examples.html">Command Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="backup.html">Backup</a></li>
<li class="toctree-l1"><a class="reference internal" href="writing-raw-data.html">Writing Raw Data</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Scripting API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#execute-script">Execute Script</a></li>
<li class="toctree-l2"><a class="reference internal" href="#command-line">Command Line</a></li>
<li class="toctree-l2"><a class="reference internal" href="#functions">Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#types">Types</a></li>
<li class="toctree-l2"><a class="reference internal" href="#objects">Objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="#mime-types">MIME Types</a></li>
<li class="toctree-l2"><a class="reference internal" href="#selected-items">Selected Items</a></li>
<li class="toctree-l2"><a class="reference internal" href="#plugins">Plugins</a></li>
</ul>
</li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build-source-code.html">Build from Source Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="fixing-bugs.html">Fixing Bugs and Adding Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="source-code-overview.html">Source Code Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="translations.html">Translations</a></li>
<li class="toctree-l1"><a class="reference internal" href="text-encoding.html">Text Encoding</a></li>
<li class="toctree-l1"><a class="reference internal" href="customize-and-build-the-windows-installer.html">Customize and Build the Windows Installer</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">CopyQ</a>
        
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>Scripting API</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/scripting-api.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="scripting-api">
<span id="id1"></span><h1>Scripting API<a class="headerlink" href="#scripting-api" title="Permalink to this headline"></a></h1>
<p>CopyQ provides scripting capabilities to automatically handle clipboard
changes, organize items, change settings and much more.</p>
<p>In addition to features provided by Qt Script there are following
<a class="reference internal" href="#functions">functions</a>, <a class="reference internal" href="#types">types</a>, <a class="reference internal" href="#objects">objects</a> and <a class="reference internal" href="#mime-types">MIME types</a>.</p>
<div class="section" id="execute-script">
<h2>Execute Script<a class="headerlink" href="#execute-script" title="Permalink to this headline"></a></h2>
<p>The scripts can be executed:</p>
<ul class="simple">
<li>from commands (in Action or Command dialogs – F5, F6 shortcuts) if
the first line starts with <code class="docutils literal"><span class="pre">copyq:</span></code>,</li>
<li>from command line as <code class="docutils literal"><span class="pre">copyq</span> <span class="pre">eval</span> <span class="pre">'&lt;SCRIPT&gt;'</span></code>,</li>
<li>from command line as <code class="docutils literal"><span class="pre">cat</span> <span class="pre">script.js</span> <span class="pre">|</span> <span class="pre">copyq</span> <span class="pre">eval</span> <span class="pre">-</span></code>,</li>
<li>from command line as
<code class="docutils literal"><span class="pre">copyq</span> <span class="pre">&lt;SCRIPT_FUNCTION&gt;</span> <span class="pre">&lt;FUNCTION_ARGUMENT_1&gt;</span> <span class="pre">&lt;FUNCTION_ARGUMENT_2&gt;</span> <span class="pre">...</span></code>.</li>
</ul>
<p>When run from command line, result of last expression is printed on
stdout.</p>
<p>Command exit values are:</p>
<ul class="simple">
<li>0 - script finished without error,</li>
<li>1 - <code class="docutils literal"><span class="pre">fail()</span></code> was called,</li>
<li>2 - bad syntax,</li>
<li>3 - exception was thrown.</li>
</ul>
</div>
<div class="section" id="command-line">
<h2>Command Line<a class="headerlink" href="#command-line" title="Permalink to this headline"></a></h2>
<p>If number of arguments that can be passed to function is limited you can
use</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq &lt;FUNCTION1&gt; &lt;FUNCTION1_ARGUMENT_1&gt; &lt;FUNCTION1_ARGUMENT_2&gt; <span class="se">\</span>
          &lt;FUNCTION2&gt; &lt;FUNCTION2_ARGUMENT&gt; <span class="se">\</span>
              &lt;FUNCTION3&gt; &lt;FUNCTION3_ARGUMENTS&gt; ...
</pre></div>
</div>
<p>where <code class="docutils literal"><span class="pre">&lt;FUNCTION1&gt;</span></code> and <code class="docutils literal"><span class="pre">&lt;FUNCTION2&gt;</span></code> are scripts where result of
last expression is functions that take two and one arguments
respectively.</p>
<p>E.g.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq tab clipboard separator <span class="s2">&quot;,&quot;</span> <span class="nb">read</span> <span class="m">0</span> <span class="m">1</span> <span class="m">2</span>
</pre></div>
</div>
<p>After <code class="docutils literal"><span class="pre">eval</span></code> no arguments are treated as functions since it can access
all arguments.</p>
<p>Arguments recognize escape sequences <code class="docutils literal"><span class="pre">\n</span></code> (new line), <code class="docutils literal"><span class="pre">\t</span></code>
(tabulator character) and <code class="docutils literal"><span class="pre">\\</span></code> (backslash).</p>
<p>Argument <code class="docutils literal"><span class="pre">-e</span></code> is identical to <code class="docutils literal"><span class="pre">eval</span></code>.</p>
<p>Argument <code class="docutils literal"><span class="pre">-</span></code> is replaced with data read from stdin.</p>
<p>Argument <code class="docutils literal"><span class="pre">--</span></code> is skipped and all the remaining arguments are
interpreted as they are (escape sequences are ignored and <code class="docutils literal"><span class="pre">-e</span></code>, <code class="docutils literal"><span class="pre">-</span></code>,
<code class="docutils literal"><span class="pre">--</span></code> are left unchanged).</p>
</div>
<div class="section" id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline"></a></h2>
<p>Argument list parts <code class="docutils literal"><span class="pre">...</span></code> and <code class="docutils literal"><span class="pre">[...]</span></code> are optional and can be
omitted.</p>
<dl class="function">
<dt id="String version">
<code class="descname">String version</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String version" title="Permalink to this definition"></a></dt>
<dd><p>Returns version string.</p>
</dd></dl>

<dl class="function">
<dt id="String help">
<code class="descname">String help</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String help" title="Permalink to this definition"></a></dt>
<dd><p>Returns help string.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">String help</code><span class="sig-paren">(</span><em>searchString</em>, <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Returns help for matched commands.</p>
</dd></dl>

<dl class="function">
<dt id="show">
<code class="descname">show</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#show" title="Permalink to this definition"></a></dt>
<dd><p>Shows main window.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">show</code><span class="sig-paren">(</span><em>tabName</em><span class="sig-paren">)</span></dt>
<dd><p>Shows tab.</p>
</dd></dl>

<dl class="function">
<dt id="showAt">
<code class="descname">showAt</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#showAt" title="Permalink to this definition"></a></dt>
<dd><p>Shows main window under mouse cursor.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">showAt</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="optional">[</span>, <em>width</em>, <em>height</em><span class="optional">]</span><span class="sig-paren">)</span></dt>
<dd><p>Shows main window with given geometry.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">showAt</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>width</em>, <em>height</em>, <em>tabName</em><span class="sig-paren">)</span></dt>
<dd><p>Shows tab with given geometry.</p>
</dd></dl>

<dl class="function">
<dt id="hide">
<code class="descname">hide</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hide" title="Permalink to this definition"></a></dt>
<dd><p>Hides main window.</p>
</dd></dl>

<dl class="function">
<dt id="bool toggle">
<code class="descname">bool toggle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bool toggle" title="Permalink to this definition"></a></dt>
<dd><p>Shows or hides main window.</p>
<p>Returns true only if main window is being shown.</p>
</dd></dl>

<dl class="function">
<dt id="menu">
<code class="descname">menu</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#menu" title="Permalink to this definition"></a></dt>
<dd><p>Opens context menu.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">menu</code><span class="sig-paren">(</span><em>tabName</em><span class="optional">[</span>, <em>maxItemCount</em><span class="optional">[</span>, <em>x</em>, <em>y</em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span></dt>
<dd><p>Shows context menu for given tab.</p>
<p>This menu doesn’t show clipboard and doesn’t have any special actions.</p>
<p>Second argument is optional maximum number of items. The default value
same as for tray (i.e. value of <code class="docutils literal"><span class="pre">config('tray_items')</span></code>).</p>
<p>Optional arguments x, y are coordinates in pixels on screen where menu
should show up. By default menu shows up under the mouse cursor.</p>
</dd></dl>

<dl class="function">
<dt id="exit">
<code class="descname">exit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#exit" title="Permalink to this definition"></a></dt>
<dd><p>Exits server.</p>
</dd></dl>

<dl class="function">
<dt id="disable">
<code class="descname">disable</code><span class="sig-paren">(</span><em>)</em>, <em>enable(</em><span class="sig-paren">)</span><a class="headerlink" href="#disable" title="Permalink to this definition"></a></dt>
<dd><p>Disables or enables clipboard content storing.</p>
</dd></dl>

<dl class="function">
<dt id="bool monitoring">
<code class="descname">bool monitoring</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bool monitoring" title="Permalink to this definition"></a></dt>
<dd><p>Returns true only if clipboard storing is enabled.</p>
</dd></dl>

<dl class="function">
<dt id="bool visible">
<code class="descname">bool visible</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bool visible" title="Permalink to this definition"></a></dt>
<dd><p>Returns true only if main window is visible.</p>
</dd></dl>

<dl class="function">
<dt id="bool focused">
<code class="descname">bool focused</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bool focused" title="Permalink to this definition"></a></dt>
<dd><p>Returns true only if main window has focus.</p>
</dd></dl>

<dl class="function">
<dt id="filter">
<code class="descname">filter</code><span class="sig-paren">(</span><em>filterText</em><span class="sig-paren">)</span><a class="headerlink" href="#filter" title="Permalink to this definition"></a></dt>
<dd><p>Sets text for filtering items in main window.</p>
</dd></dl>

<dl class="function">
<dt id="ignore">
<code class="descname">ignore</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ignore" title="Permalink to this definition"></a></dt>
<dd><p>Ignores current clipboard content (used for automatic commands).</p>
<p>This does all of the below.</p>
<ul class="simple">
<li>Skips any next automatic commands.</li>
<li>Omits changing window title and tray tool tip.</li>
<li>Won’t store content in clipboard tab.</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="ByteArray clipboard">
<code class="descname">ByteArray clipboard</code><span class="sig-paren">(</span><span class="optional">[</span><em>mimeType</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray clipboard" title="Permalink to this definition"></a></dt>
<dd><p>Returns clipboard data for MIME type (default is text).</p>
<p>Pass argument <code class="docutils literal"><span class="pre">&quot;?&quot;</span></code> to list available MIME types.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray selection">
<code class="descname">ByteArray selection</code><span class="sig-paren">(</span><span class="optional">[</span><em>mimeType</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray selection" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">clipboard()</span></code> for Linux/X11 mouse selection.</p>
</dd></dl>

<dl class="function">
<dt id="bool hasClipboardFormat">
<code class="descname">bool hasClipboardFormat</code><span class="sig-paren">(</span><em>mimeType</em><span class="sig-paren">)</span><a class="headerlink" href="#bool hasClipboardFormat" title="Permalink to this definition"></a></dt>
<dd><p>Returns true only if clipboard contains MIME type.</p>
</dd></dl>

<dl class="function">
<dt id="bool hasSelectionFormat">
<code class="descname">bool hasSelectionFormat</code><span class="sig-paren">(</span><em>mimeType</em><span class="sig-paren">)</span><a class="headerlink" href="#bool hasSelectionFormat" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">hasClipboardFormat()</span></code> for Linux/X11 mouse selection.</p>
</dd></dl>

<dl class="function">
<dt id="bool isClipboard">
<code class="descname">bool isClipboard</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#bool isClipboard" title="Permalink to this definition"></a></dt>
<dd><p>Returns true only in automatic command triggered by clipboard change.</p>
<p>This can be used to check if current automatic command was triggered by
clipboard and not Linux/X11 mouse selection change.</p>
</dd></dl>

<dl class="function">
<dt id="bool copy">
<code class="descname">bool copy</code><span class="sig-paren">(</span><em>text</em><span class="sig-paren">)</span><a class="headerlink" href="#bool copy" title="Permalink to this definition"></a></dt>
<dd><p>Sets clipboard plain text.</p>
<p>Same as <code class="docutils literal"><span class="pre">copy(mimeText,</span> <span class="pre">text)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">bool copy</code><span class="sig-paren">(</span><em>mimeType, data, [mimeType, data]...</em><span class="sig-paren">)</span></dt>
<dd><p>Sets clipboard data.</p>
<p>This also sets <code class="docutils literal"><span class="pre">mimeOwner</span></code> format so automatic commands are not run on
the new data and it’s not store in clipboard tab.</p>
<p>Exception is thrown if clipboard fails to be set.</p>
<p>Example (set both text and rich text):</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">copy</span><span class="p">(</span><span class="nx">mimeText</span><span class="p">,</span> <span class="s1">&#39;Hello, World!&#39;</span><span class="p">,</span>
     <span class="nx">mimeHtml</span><span class="p">,</span> <span class="s1">&#39;&lt;p&gt;Hello, World!&lt;/p&gt;&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">bool copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dd><p>Sends <code class="docutils literal"><span class="pre">Ctrl+C</span></code> to current window.</p>
<p>Exception is thrown if clipboard doesn’t change (clipboard is reset
before sending the shortcut).</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray copySelection">
<code class="descname">ByteArray copySelection</code><span class="sig-paren">(</span><em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray copySelection" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">copy(...)</span></code> for Linux/X11 mouse selection.</p>
</dd></dl>

<dl class="function">
<dt id="paste">
<code class="descname">paste</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#paste" title="Permalink to this definition"></a></dt>
<dd><p>Pastes current clipboard.</p>
<p>This is basically only sending <code class="docutils literal"><span class="pre">Shift+Insert</span></code> shortcut to current
window.</p>
<p>Correct functionality depends a lot on target application and window
manager.</p>
</dd></dl>

<dl class="function">
<dt id="Array tab">
<code class="descname">Array tab</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Array tab" title="Permalink to this definition"></a></dt>
<dd><p>Returns array of with tab names.</p>
</dd></dl>

<dl class="function">
<dt id="tab">
<code class="descname">tab</code><span class="sig-paren">(</span><em>tabName</em><span class="sig-paren">)</span><a class="headerlink" href="#tab" title="Permalink to this definition"></a></dt>
<dd><p>Sets current tab for the script.</p>
<p>E.g. following script selects third item (index is 2) from tab “Notes”.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">tab</span><span class="p">(</span><span class="s1">&#39;Notes&#39;</span><span class="p">)</span>
<span class="nx">select</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="removeTab">
<code class="descname">removeTab</code><span class="sig-paren">(</span><em>tabName</em><span class="sig-paren">)</span><a class="headerlink" href="#removeTab" title="Permalink to this definition"></a></dt>
<dd><p>Removes tab.</p>
</dd></dl>

<dl class="function">
<dt id="renameTab">
<code class="descname">renameTab</code><span class="sig-paren">(</span><em>tabName</em>, <em>newTabName</em><span class="sig-paren">)</span><a class="headerlink" href="#renameTab" title="Permalink to this definition"></a></dt>
<dd><p>Renames tab.</p>
</dd></dl>

<dl class="function">
<dt id="String tabIcon">
<code class="descname">String tabIcon</code><span class="sig-paren">(</span><em>tabName</em><span class="sig-paren">)</span><a class="headerlink" href="#String tabIcon" title="Permalink to this definition"></a></dt>
<dd><p>Returns path to icon for tab.</p>
</dd></dl>

<dl class="function">
<dt id="tabIcon">
<code class="descname">tabIcon</code><span class="sig-paren">(</span><em>tabName</em>, <em>iconPath</em><span class="sig-paren">)</span><a class="headerlink" href="#tabIcon" title="Permalink to this definition"></a></dt>
<dd><p>Sets icon for tab.</p>
</dd></dl>

<dl class="function">
<dt id="count">
<code class="descname">count</code><span class="sig-paren">(</span><em>)</em>, <em>length()</em>, <em>size(</em><span class="sig-paren">)</span><a class="headerlink" href="#count" title="Permalink to this definition"></a></dt>
<dd><p>Returns amount of items in current tab.</p>
</dd></dl>

<dl class="function">
<dt id="select">
<code class="descname">select</code><span class="sig-paren">(</span><em>row</em><span class="sig-paren">)</span><a class="headerlink" href="#select" title="Permalink to this definition"></a></dt>
<dd><p>Copies item in the row to clipboard.</p>
<p>Additionally, moves selected item to top depending on settings.</p>
</dd></dl>

<dl class="function">
<dt id="next">
<code class="descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#next" title="Permalink to this definition"></a></dt>
<dd><p>Copies next item from current tab to clipboard.</p>
</dd></dl>

<dl class="function">
<dt id="previous">
<code class="descname">previous</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#previous" title="Permalink to this definition"></a></dt>
<dd><p>Copies previous item from current tab to clipboard.</p>
</dd></dl>

<dl class="function">
<dt id="add">
<code class="descname">add</code><span class="sig-paren">(</span><em>text|item...</em><span class="sig-paren">)</span><a class="headerlink" href="#add" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">insert(0,</span> <span class="pre">...)</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="insert">
<code class="descname">insert</code><span class="sig-paren">(</span><em>row</em>, <em>text|item...</em><span class="sig-paren">)</span><a class="headerlink" href="#insert" title="Permalink to this definition"></a></dt>
<dd><p>Inserts new items to current tab.</p>
<p>Throws an exception if space for the items cannot be allocated.</p>
</dd></dl>

<dl class="function">
<dt id="remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>row</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#remove" title="Permalink to this definition"></a></dt>
<dd><p>Removes items in current tab.</p>
<p>Throws an exception if some items cannot be removed.</p>
</dd></dl>

<dl class="function">
<dt id="edit">
<code class="descname">edit</code><span class="sig-paren">(</span><em>[row|text] ...</em><span class="sig-paren">)</span><a class="headerlink" href="#edit" title="Permalink to this definition"></a></dt>
<dd><p>Edits items in current tab.</p>
<p>Opens external editor if set, otherwise opens internal editor.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray read([mimeType]);">
<code class="descname">ByteArray read([mimeType]);</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray read([mimeType]);" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">clipboard()</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray read(mimeType, row, ...);">
<code class="descclassname">ByteArray read(mimeType, row, ...</code><code class="descname">);</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray read(mimeType, row, ...);" title="Permalink to this definition"></a></dt>
<dd><p>Returns concatenated data from items or clipboard if row is negative.</p>
<p>Pass argument <code class="docutils literal"><span class="pre">&quot;?&quot;</span></code> to list available MIME types.</p>
</dd></dl>

<dl class="function">
<dt id="write">
<code class="descname">write</code><span class="sig-paren">(</span><em>row, mimeType, data, [mimeType, data]...</em><span class="sig-paren">)</span><a class="headerlink" href="#write" title="Permalink to this definition"></a></dt>
<dd><p>Inserts new item to current tab.</p>
<p>Throws an exception if space for the items cannot be allocated.</p>
</dd></dl>

<dl class="function">
<dt id="change">
<code class="descname">change</code><span class="sig-paren">(</span><em>row, mimeType, data, [mimeType, data]...</em><span class="sig-paren">)</span><a class="headerlink" href="#change" title="Permalink to this definition"></a></dt>
<dd><p>Changes data in item in current tab.</p>
<p>If data is <code class="docutils literal"><span class="pre">undefined</span></code> the format is removed from item.</p>
</dd></dl>

<dl class="function">
<dt id="String separator">
<code class="descname">String separator</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String separator" title="Permalink to this definition"></a></dt>
<dd><p>Returns item separator (used when concatenating item data).</p>
</dd></dl>

<dl class="function">
<dt id="separator">
<code class="descname">separator</code><span class="sig-paren">(</span><em>separator</em><span class="sig-paren">)</span><a class="headerlink" href="#separator" title="Permalink to this definition"></a></dt>
<dd><p>Sets item separator for concatenating item data.</p>
</dd></dl>

<dl class="function">
<dt id="action">
<code class="descname">action</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#action" title="Permalink to this definition"></a></dt>
<dd><p>Opens action dialog.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">action</code><span class="sig-paren">(</span><em>row</em>, <em>...</em>, <em>command</em>, <em>outputItemSeparator</em><span class="sig-paren">)</span></dt>
<dd><p>Runs command for items in current tab.</p>
</dd></dl>

<dl class="function">
<dt id="popup">
<code class="descname">popup</code><span class="sig-paren">(</span><em>title</em>, <em>message</em><span class="optional">[</span>, <em>time=8000</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#popup" title="Permalink to this definition"></a></dt>
<dd><p>Shows popup message for given time in milliseconds.</p>
<p>If <code class="docutils literal"><span class="pre">time</span></code> argument is set to -1, the popup is hidden only after mouse
click.</p>
</dd></dl>

<dl class="function">
<dt id="notification">
<code class="descname">notification</code><span class="sig-paren">(</span><em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#notification" title="Permalink to this definition"></a></dt>
<dd><p>Shows popup message with icon and buttons.</p>
<p>Each button can have script and data.</p>
<p>If button is clicked the notification is hidden and script is executed
with the data passed as stdin.</p>
<p>The function returns immediately (doesn’t wait on user input).</p>
<p>Special arguments:</p>
<ul class="simple">
<li>‘.title’ - notification title</li>
<li>‘.message’ - notification message (can contain basic HTML)</li>
<li>‘.icon’ - notification icon (path to image or font icon)</li>
<li>‘.id’ - notification ID - this replaces notification with same ID</li>
<li>‘.time’ - duration of notification in milliseconds (default is -1,
i.e. waits for mouse click)</li>
<li>‘.button’ - adds button (three arguments: name, script and data)</li>
</ul>
<p>Example:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">notification</span><span class="p">(</span>
      <span class="s1">&#39;.title&#39;</span><span class="p">,</span> <span class="s1">&#39;Example&#39;</span><span class="p">,</span>
      <span class="s1">&#39;.message&#39;</span><span class="p">,</span> <span class="s1">&#39;Notification with button&#39;</span><span class="p">,</span>
      <span class="s1">&#39;.button&#39;</span><span class="p">,</span> <span class="s1">&#39;Cancel&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
      <span class="s1">&#39;.button&#39;</span><span class="p">,</span> <span class="s1">&#39;OK&#39;</span><span class="p">,</span> <span class="s1">&#39;copyq:popup(input())&#39;</span><span class="p">,</span> <span class="s1">&#39;OK Clicked&#39;</span>
      <span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="exportTab">
<code class="descname">exportTab</code><span class="sig-paren">(</span><em>fileName</em><span class="sig-paren">)</span><a class="headerlink" href="#exportTab" title="Permalink to this definition"></a></dt>
<dd><p>Exports current tab into file.</p>
</dd></dl>

<dl class="function">
<dt id="importTab">
<code class="descname">importTab</code><span class="sig-paren">(</span><em>fileName</em><span class="sig-paren">)</span><a class="headerlink" href="#importTab" title="Permalink to this definition"></a></dt>
<dd><p>Imports items from file to a new tab.</p>
</dd></dl>

<dl class="function">
<dt id="String config">
<code class="descname">String config</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String config" title="Permalink to this definition"></a></dt>
<dd><p>Returns help with list of available options.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">String config</code><span class="sig-paren">(</span><em>optionName</em><span class="sig-paren">)</span></dt>
<dd><p>Returns value of given option.</p>
<p>Throws an exception if the option is invalid.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">String config</code><span class="sig-paren">(</span><em>optionName</em>, <em>value</em><span class="sig-paren">)</span></dt>
<dd><p>Sets option and returns new value.</p>
<p>Throws an exception if the option is invalid.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">String config</code><span class="sig-paren">(</span><em>optionName</em>, <em>value</em>, <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Sets multiple options and return list with values in format <code class="docutils literal"><span class="pre">optionName=newValue</span></code>.</p>
<p>Throws an exception if there is an invalid option in which case it won’t
set any options.</p>
</dd></dl>

<dl class="function">
<dt id="bool toggleConfig">
<code class="descname">bool toggleConfig</code><span class="sig-paren">(</span><em>optionName</em><span class="sig-paren">)</span><a class="headerlink" href="#bool toggleConfig" title="Permalink to this definition"></a></dt>
<dd><p>Toggles an option (true to false and vice versa) and returns the new value.</p>
</dd></dl>

<dl class="function">
<dt id="String info">
<code class="descname">String info</code><span class="sig-paren">(</span><span class="optional">[</span><em>pathName</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#String info" title="Permalink to this definition"></a></dt>
<dd><p>Returns paths and flags used by the application.</p>
<p>E.g. following command prints path to configuration file.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq info config
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="Value eval">
<code class="descname">Value eval</code><span class="sig-paren">(</span><em>script</em><span class="sig-paren">)</span><a class="headerlink" href="#Value eval" title="Permalink to this definition"></a></dt>
<dd><p>Evaluates script and returns result.</p>
</dd></dl>

<dl class="function">
<dt id="Value source">
<code class="descname">Value source</code><span class="sig-paren">(</span><em>fileName</em><span class="sig-paren">)</span><a class="headerlink" href="#Value source" title="Permalink to this definition"></a></dt>
<dd><p>Evaluates script file and returns result of last expression in the script.</p>
<p>This is useful to move some common code out of commands.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="c1">// File: c:/copyq/replace_clipboard_text.js</span>
<span class="nx">replaceClipboardText</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">replaceWhat</span><span class="p">,</span> <span class="nx">replaceWith</span><span class="p">)</span>
<span class="p">{</span>
    <span class="kd">var</span> <span class="nx">text</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="nx">clipboard</span><span class="p">())</span>
    <span class="kd">var</span> <span class="nx">newText</span> <span class="o">=</span> <span class="nx">text</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">replaceWhat</span><span class="p">,</span> <span class="nx">replaceWith</span><span class="p">)</span>
    <span class="k">if</span> <span class="p">(</span><span class="nx">text</span> <span class="o">!=</span> <span class="nx">newText</span><span class="p">)</span>
        <span class="nx">copy</span><span class="p">(</span><span class="nx">newText</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">source</span><span class="p">(</span><span class="s1">&#39;c:/copyq/replace_clipboard_text.js&#39;</span><span class="p">)</span>
<span class="nx">replaceClipboardText</span><span class="p">(</span><span class="s1">&#39;secret&#39;</span><span class="p">,</span> <span class="s1">&#39;*****&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="String currentPath">
<code class="descname">String currentPath</code><span class="sig-paren">(</span><span class="optional">[</span><em>path</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#String currentPath" title="Permalink to this definition"></a></dt>
<dd><p>Get or set current path.</p>
</dd></dl>

<dl class="function">
<dt id="String str">
<code class="descname">String str</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#String str" title="Permalink to this definition"></a></dt>
<dd><p>Converts a value to string.</p>
<p>If ByteArray object is the argument, it assumes UTF8 encoding. To use
different encoding, use <code class="docutils literal"><span class="pre">toUnicode()</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray input">
<code class="descname">ByteArray input</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray input" title="Permalink to this definition"></a></dt>
<dd><p>Returns standard input passed to the script.</p>
</dd></dl>

<dl class="function">
<dt id="String toUnicode">
<code class="descname">String toUnicode</code><span class="sig-paren">(</span><em>ByteArray</em>, <em>encodingName</em><span class="sig-paren">)</span><a class="headerlink" href="#String toUnicode" title="Permalink to this definition"></a></dt>
<dd><p>Returns string for bytes with given encoding.</p>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">String toUnicode</code><span class="sig-paren">(</span><em>ByteArray</em><span class="sig-paren">)</span></dt>
<dd><p>Returns string for bytes with encoding detected by checking Byte Order Mark (BOM).</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray fromUnicode">
<code class="descname">ByteArray fromUnicode</code><span class="sig-paren">(</span><em>String</em>, <em>encodingName</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray fromUnicode" title="Permalink to this definition"></a></dt>
<dd><p>Returns encoded text.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray data">
<code class="descname">ByteArray data</code><span class="sig-paren">(</span><em>mimeType</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray data" title="Permalink to this definition"></a></dt>
<dd><p>Returns data for automatic commands or selected items.</p>
<p>If run from menu or using non-global shortcut the data are taken from
selected items.</p>
<p>If run for automatic command the data are clipboard content.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray setData">
<code class="descname">ByteArray setData</code><span class="sig-paren">(</span><em>mimeType</em>, <em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray setData" title="Permalink to this definition"></a></dt>
<dd><p>Modifies data for <code class="docutils literal"><span class="pre">data()</span></code> and new clipboard item.</p>
<p>Next automatic command will get updated data.</p>
<p>This is also the data used to create new item from clipboard.</p>
<p>E.g. following automatic command will add creation time data and tag to
new items.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">copyq</span><span class="p">:</span>
<span class="n">var</span> <span class="n">timeFormat</span> <span class="o">=</span> <span class="s1">&#39;yyyy-MM-dd hh:mm:ss&#39;</span>
<span class="n">setData</span><span class="p">(</span><span class="s1">&#39;application/x-copyq-user-copy-time&#39;</span><span class="p">,</span> <span class="n">dateString</span><span class="p">(</span><span class="n">timeFormat</span><span class="p">))</span>
<span class="n">setData</span><span class="p">(</span><span class="n">mimeTags</span><span class="p">,</span> <span class="s1">&#39;copied: &#39;</span> <span class="o">+</span> <span class="n">time</span><span class="p">)</span>
</pre></div>
</div>
<p>E.g. following menu command will add tag to selected items.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">copyq</span><span class="p">:</span>
<span class="n">setData</span><span class="p">(</span><span class="s1">&#39;application/x-copyq-tags&#39;</span><span class="p">,</span> <span class="s1">&#39;Important&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="ByteArray removeData">
<code class="descname">ByteArray removeData</code><span class="sig-paren">(</span><em>mimeType</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray removeData" title="Permalink to this definition"></a></dt>
<dd><p>Removes data for <code class="docutils literal"><span class="pre">data()</span></code> and new clipboard item.</p>
</dd></dl>

<dl class="function">
<dt id="Array dataFormats">
<code class="descname">Array dataFormats</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Array dataFormats" title="Permalink to this definition"></a></dt>
<dd><p>Returns formats available for <code class="docutils literal"><span class="pre">data()</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="print">
<code class="descname">print</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#print" title="Permalink to this definition"></a></dt>
<dd><p>Prints value to standard output.</p>
</dd></dl>

<dl class="function">
<dt id="abort">
<code class="descname">abort</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#abort" title="Permalink to this definition"></a></dt>
<dd><p>Aborts script evaluation.</p>
</dd></dl>

<dl class="function">
<dt id="fail">
<code class="descname">fail</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#fail" title="Permalink to this definition"></a></dt>
<dd><p>Aborts script evaluation with nonzero exit code.</p>
</dd></dl>

<dl class="function">
<dt id="setCurrentTab">
<code class="descname">setCurrentTab</code><span class="sig-paren">(</span><em>tabName</em><span class="sig-paren">)</span><a class="headerlink" href="#setCurrentTab" title="Permalink to this definition"></a></dt>
<dd><p>Focus tab without showing main window.</p>
</dd></dl>

<dl class="function">
<dt id="selectItems">
<code class="descname">selectItems</code><span class="sig-paren">(</span><em>row</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#selectItems" title="Permalink to this definition"></a></dt>
<dd><p>Selects items in current tab.</p>
</dd></dl>

<dl class="function">
<dt id="String selectedTab">
<code class="descname">String selectedTab</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String selectedTab" title="Permalink to this definition"></a></dt>
<dd><p>Returns tab that was selected when script was executed.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="[row, ...] selectedItems">
<code class="descclassname">[row, ...</code><code class="descname">] selectedItems</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#[row, ...] selectedItems" title="Permalink to this definition"></a></dt>
<dd><p>Returns selected rows in current tab.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="Item selectedItemData">
<code class="descname">Item selectedItemData</code><span class="sig-paren">(</span><em>index</em><span class="sig-paren">)</span><a class="headerlink" href="#Item selectedItemData" title="Permalink to this definition"></a></dt>
<dd><p>Returns data for given selected item.</p>
<p>The data can empty if the item was removed during execution of the
script.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="bool setSelectedItemData">
<code class="descname">bool setSelectedItemData</code><span class="sig-paren">(</span><em>index</em>, <em>item</em><span class="sig-paren">)</span><a class="headerlink" href="#bool setSelectedItemData" title="Permalink to this definition"></a></dt>
<dd><p>Set data for given selected item.</p>
<p>Returns false only if the data cannot be set, usually if item was
removed.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="Item[] selectedItemsData">
<code class="descname">Item[] selectedItemsData</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Item[] selectedItemsData" title="Permalink to this definition"></a></dt>
<dd><p>Returns data for all selected item.</p>
<p>Some data can empty if the item was removed during execution of the
script.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="void setSelectedItemsData">
<code class="descname">void setSelectedItemsData</code><span class="sig-paren">(</span><em>item[]</em><span class="sig-paren">)</span><a class="headerlink" href="#void setSelectedItemsData" title="Permalink to this definition"></a></dt>
<dd><p>Set data to all selected items.</p>
<p>Some data may not be set if the item was removed during execution of the
script.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="int currentItem">
<code class="descname">int currentItem</code><span class="sig-paren">(</span><em>)</em>, <em>int index(</em><span class="sig-paren">)</span><a class="headerlink" href="#int currentItem" title="Permalink to this definition"></a></dt>
<dd><p>Returns current row in current tab.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="String escapeHtml">
<code class="descname">String escapeHtml</code><span class="sig-paren">(</span><em>text</em><span class="sig-paren">)</span><a class="headerlink" href="#String escapeHtml" title="Permalink to this definition"></a></dt>
<dd><p>Returns text with special HTML characters escaped.</p>
</dd></dl>

<dl class="function">
<dt id="Item unpack">
<code class="descname">Item unpack</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#Item unpack" title="Permalink to this definition"></a></dt>
<dd><p>Returns deserialized object from serialized items.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray pack">
<code class="descname">ByteArray pack</code><span class="sig-paren">(</span><em>item</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray pack" title="Permalink to this definition"></a></dt>
<dd><p>Returns serialized item.</p>
</dd></dl>

<dl class="function">
<dt id="Item getItem">
<code class="descname">Item getItem</code><span class="sig-paren">(</span><em>row</em><span class="sig-paren">)</span><a class="headerlink" href="#Item getItem" title="Permalink to this definition"></a></dt>
<dd><p>Returns an item in current tab.</p>
</dd></dl>

<dl class="function">
<dt id="setItem">
<code class="descname">setItem</code><span class="sig-paren">(</span><em>row</em>, <em>text|item</em><span class="sig-paren">)</span><a class="headerlink" href="#setItem" title="Permalink to this definition"></a></dt>
<dd><p>Inserts item to current tab.</p>
</dd></dl>

<dl class="function">
<dt id="String toBase64">
<code class="descname">String toBase64</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#String toBase64" title="Permalink to this definition"></a></dt>
<dd><p>Returns base64-encoded data.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray fromBase64">
<code class="descname">ByteArray fromBase64</code><span class="sig-paren">(</span><em>base64String</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray fromBase64" title="Permalink to this definition"></a></dt>
<dd><p>Returns base64-decoded data.</p>
</dd></dl>

<dl class="function">
<dt id="bool open">
<code class="descname">bool open</code><span class="sig-paren">(</span><em>url</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#bool open" title="Permalink to this definition"></a></dt>
<dd><p>Tries to open URLs in appropriate applications.</p>
<p>Returns true only if all URLs were successfully opened.</p>
</dd></dl>

<dl class="function">
<dt id="FinishedCommand execute">
<code class="descname">FinishedCommand execute</code><span class="sig-paren">(</span><em>argument</em>, <em>...</em>, <em>null</em>, <em>stdinData</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#FinishedCommand execute" title="Permalink to this definition"></a></dt>
<dd><p>Executes a command.</p>
<p>All arguments after <code class="docutils literal"><span class="pre">null</span></code> are passed to standard input of the
command.</p>
<p>If arguments is function it will be called with array of lines read from
stdout whenever available.</p>
<p>E.g. create item for each line on stdout:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">execute</span><span class="p">(</span><span class="s1">&#39;tail&#39;</span><span class="p">,</span> <span class="s1">&#39;-f&#39;</span><span class="p">,</span> <span class="s1">&#39;some_file.log&#39;</span><span class="p">,</span>
        <span class="kd">function</span><span class="p">(</span><span class="nx">lines</span><span class="p">)</span> <span class="p">{</span> <span class="nx">add</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">lines</span><span class="p">)</span> <span class="p">})</span>
</pre></div>
</div>
<p>Returns object for the finished command or <code class="docutils literal"><span class="pre">undefined</span></code> on failure.</p>
</dd></dl>

<dl class="function">
<dt id="String currentWindowTitle">
<code class="descname">String currentWindowTitle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String currentWindowTitle" title="Permalink to this definition"></a></dt>
<dd><p>Returns window title of currently focused window.</p>
</dd></dl>

<dl class="function">
<dt id="Value dialog">
<code class="descname">Value dialog</code><span class="sig-paren">(</span><em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#Value dialog" title="Permalink to this definition"></a></dt>
<dd><p>Shows messages or asks user for input.</p>
<p>Arguments are names and associated values.</p>
<p>Special arguments:</p>
<ul class="simple">
<li>‘.title’ - dialog title</li>
<li>‘.icon’ - dialog icon (see below for more info)</li>
<li>‘.style’ - Qt style sheet for dialog</li>
<li>‘.height’, ‘.width’, ‘.x’, ‘.y’ - dialog geometry</li>
<li>‘.label’ - dialog message (can contain basic HTML)</li>
</ul>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">dialog</span><span class="p">(</span>
  <span class="s1">&#39;.title&#39;</span><span class="p">,</span> <span class="s1">&#39;Command Finished&#39;</span><span class="p">,</span>
  <span class="s1">&#39;.label&#39;</span><span class="p">,</span> <span class="s1">&#39;Command &lt;b&gt;successfully&lt;/b&gt; finished.&#39;</span>
  <span class="p">)</span>
</pre></div>
</div>
<p>Other arguments are used to get user input.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">amount</span> <span class="o">=</span> <span class="nx">dialog</span><span class="p">(</span><span class="s1">&#39;.title&#39;</span><span class="p">,</span> <span class="s1">&#39;Amount?&#39;</span><span class="p">,</span> <span class="s1">&#39;Enter Amount&#39;</span><span class="p">,</span> <span class="s1">&#39;n/a&#39;</span><span class="p">)</span>
<span class="kd">var</span> <span class="nx">filePath</span> <span class="o">=</span> <span class="nx">dialog</span><span class="p">(</span><span class="s1">&#39;.title&#39;</span><span class="p">,</span> <span class="s1">&#39;File?&#39;</span><span class="p">,</span> <span class="s1">&#39;Choose File&#39;</span><span class="p">,</span> <span class="k">new</span> <span class="nx">File</span><span class="p">(</span><span class="s1">&#39;/home&#39;</span><span class="p">))</span>
</pre></div>
</div>
<p>If multiple inputs are required, object is returned.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">result</span> <span class="o">=</span> <span class="nx">dialog</span><span class="p">(</span>
  <span class="s1">&#39;Enter Amount&#39;</span><span class="p">,</span> <span class="s1">&#39;n/a&#39;</span><span class="p">,</span>
  <span class="s1">&#39;Choose File&#39;</span><span class="p">,</span> <span class="k">new</span> <span class="nx">File</span><span class="p">(</span><span class="nx">str</span><span class="p">(</span><span class="nx">currentPath</span><span class="p">))</span>
  <span class="p">)</span>
<span class="nx">print</span><span class="p">(</span><span class="s1">&#39;Amount: &#39;</span> <span class="o">+</span> <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;Enter Amount&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span><span class="p">)</span>
<span class="nx">print</span><span class="p">(</span><span class="s1">&#39;File: &#39;</span> <span class="o">+</span> <span class="nx">result</span><span class="p">[</span><span class="s1">&#39;Choose File&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;\n&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Editable combo box can be created by passing array. Current value can be
provided using <code class="docutils literal"><span class="pre">.defaultChoice</span></code> (by default it’s the first item).</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">text</span> <span class="o">=</span> <span class="nx">dialog</span><span class="p">(</span><span class="s1">&#39;.defaultChoice&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;Select&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">])</span>
</pre></div>
</div>
<p>List can be created by prefixing name/label with <code class="docutils literal"><span class="pre">.list:</span></code> and passing
array.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">items</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">]</span>
<span class="kd">var</span> <span class="nx">selected_index</span> <span class="o">=</span> <span class="nx">dialog</span><span class="p">(</span><span class="s1">&#39;.list:Select&#39;</span><span class="p">,</span> <span class="nx">items</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">selected_index</span><span class="p">)</span>
    <span class="nx">print</span><span class="p">(</span><span class="s1">&#39;Selected item: &#39;</span> <span class="o">+</span> <span class="nx">items</span><span class="p">[</span><span class="nx">selected_index</span><span class="p">])</span>
</pre></div>
</div>
<p>Icon for custom dialog can be set from icon font, file path or theme.
Icons from icon font can be copied from icon selection dialog in Command
dialog or dialog for setting tab icon (in menu ‘Tabs/Change Tab Icon’).</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">search</span> <span class="o">=</span> <span class="nx">dialog</span><span class="p">(</span>
  <span class="s1">&#39;.title&#39;</span><span class="p">,</span> <span class="s1">&#39;Search&#39;</span><span class="p">,</span>
  <span class="s1">&#39;.icon&#39;</span><span class="p">,</span> <span class="s1">&#39;search&#39;</span><span class="p">,</span> <span class="c1">// Set icon &#39;search&#39; from theme.</span>
  <span class="s1">&#39;Search&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span>
  <span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="Array settings">
<code class="descname">Array settings</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Array settings" title="Permalink to this definition"></a></dt>
<dd><p>Returns array with names of all custom options.</p>
</dd></dl>

<dl class="function">
<dt id="Value settings">
<code class="descname">Value settings</code><span class="sig-paren">(</span><em>optionName</em><span class="sig-paren">)</span><a class="headerlink" href="#Value settings" title="Permalink to this definition"></a></dt>
<dd><p>Returns value for an option.</p>
</dd></dl>

<dl class="function">
<dt id="settings">
<code class="descname">settings</code><span class="sig-paren">(</span><em>optionName</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#settings" title="Permalink to this definition"></a></dt>
<dd><p>Sets value for a new option or overrides existing option.</p>
</dd></dl>

<dl class="function">
<dt id="String dateString">
<code class="descname">String dateString</code><span class="sig-paren">(</span><em>format</em><span class="sig-paren">)</span><a class="headerlink" href="#String dateString" title="Permalink to this definition"></a></dt>
<dd><p>Returns text representation of current date and time.</p>
<p>See
<a class="reference external" href="http://doc.qt.io/qt-5/qdatetime.html#toString">QDateTime::toString()</a>
for details on formatting date and time.</p>
<p>Example:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">now</span> <span class="o">=</span> <span class="nx">dateString</span><span class="p">(</span><span class="s1">&#39;yyyy-MM-dd HH:mm:ss&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="Command[] commands">
<code class="descname">Command[] commands</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Command[] commands" title="Permalink to this definition"></a></dt>
<dd><p>Return list of all commands.</p>
</dd></dl>

<dl class="function">
<dt id="setCommands">
<code class="descname">setCommands</code><span class="sig-paren">(</span><em>Command[]</em><span class="sig-paren">)</span><a class="headerlink" href="#setCommands" title="Permalink to this definition"></a></dt>
<dd><p>Clear previous commands and set new ones.</p>
<p>To add new command:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">cmds</span> <span class="o">=</span> <span class="nx">commands</span><span class="p">()</span>
<span class="nx">cmds</span><span class="p">.</span><span class="nx">unshift</span><span class="p">({</span>
        <span class="nx">name</span><span class="o">:</span> <span class="s1">&#39;New Command&#39;</span><span class="p">,</span>
        <span class="nx">automatic</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
        <span class="nx">input</span><span class="o">:</span> <span class="s1">&#39;text/plain&#39;</span><span class="p">,</span>
        <span class="nx">cmd</span><span class="o">:</span> <span class="s1">&#39;copyq: popup(&quot;Clipboard&quot;, input())&#39;</span>
        <span class="p">})</span>
<span class="nx">setCommands</span><span class="p">(</span><span class="nx">cmds</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="Command[] importCommands">
<code class="descname">Command[] importCommands</code><span class="sig-paren">(</span><em>String</em><span class="sig-paren">)</span><a class="headerlink" href="#Command[] importCommands" title="Permalink to this definition"></a></dt>
<dd><p>Return list of commands from exported commands text.</p>
</dd></dl>

<dl class="function">
<dt id="String exportCommands">
<code class="descname">String exportCommands</code><span class="sig-paren">(</span><em>Command[]</em><span class="sig-paren">)</span><a class="headerlink" href="#String exportCommands" title="Permalink to this definition"></a></dt>
<dd><p>Return exported command text.</p>
</dd></dl>

<dl class="function">
<dt id="NetworkReply networkGet">
<code class="descname">NetworkReply networkGet</code><span class="sig-paren">(</span><em>url</em><span class="sig-paren">)</span><a class="headerlink" href="#NetworkReply networkGet" title="Permalink to this definition"></a></dt>
<dd><p>Sends HTTP GET request.</p>
<p>Returns reply.</p>
</dd></dl>

<dl class="function">
<dt id="NetworkReply networkPost">
<code class="descname">NetworkReply networkPost</code><span class="sig-paren">(</span><em>url</em>, <em>postData</em><span class="sig-paren">)</span><a class="headerlink" href="#NetworkReply networkPost" title="Permalink to this definition"></a></dt>
<dd><p>Sends HTTP POST request.</p>
<p>Returns reply.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray env">
<code class="descname">ByteArray env</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray env" title="Permalink to this definition"></a></dt>
<dd><p>Returns value of environment variable with given name.</p>
</dd></dl>

<dl class="function">
<dt id="bool setEnv">
<code class="descname">bool setEnv</code><span class="sig-paren">(</span><em>name</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#bool setEnv" title="Permalink to this definition"></a></dt>
<dd><p>Sets environment variable with given name to given value.</p>
<p>Returns true only if the variable was set.</p>
</dd></dl>

<dl class="function">
<dt id="sleep">
<code class="descname">sleep</code><span class="sig-paren">(</span><em>time</em><span class="sig-paren">)</span><a class="headerlink" href="#sleep" title="Permalink to this definition"></a></dt>
<dd><p>Wait for given time in milliseconds.</p>
</dd></dl>

<dl class="function">
<dt id="afterMilliseconds">
<code class="descname">afterMilliseconds</code><span class="sig-paren">(</span><em>time</em>, <em>function</em><span class="sig-paren">)</span><a class="headerlink" href="#afterMilliseconds" title="Permalink to this definition"></a></dt>
<dd><p>Executes function after given time in milliseconds.</p>
</dd></dl>

<dl class="function">
<dt id="ByteArray screenshot">
<code class="descname">ByteArray screenshot</code><span class="sig-paren">(</span><em>format='png'</em><span class="optional">[</span>, <em>screenName</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray screenshot" title="Permalink to this definition"></a></dt>
<dd><p>Returns image data with screenshot.</p>
<p>Default <code class="docutils literal"><span class="pre">screenName</span></code> is name of the screen with mouse cursor.</p>
<p>You can list valid values for <code class="docutils literal"><span class="pre">screenName</span></code> with <code class="docutils literal"><span class="pre">screenNames()</span></code>.</p>
<p>Example:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">copy</span><span class="p">(</span><span class="s1">&#39;image/png&#39;</span><span class="p">,</span> <span class="nx">screenshot</span><span class="p">())</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="ByteArray screenshotSelect">
<code class="descname">ByteArray screenshotSelect</code><span class="sig-paren">(</span><em>format='png'</em><span class="optional">[</span>, <em>screenName</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray screenshotSelect" title="Permalink to this definition"></a></dt>
<dd><p>Same as <code class="docutils literal"><span class="pre">screenshot()</span></code> but allows to select an area on screen.</p>
</dd></dl>

<dl class="function">
<dt id="String[] screenNames">
<code class="descname">String[] screenNames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String[] screenNames" title="Permalink to this definition"></a></dt>
<dd><p>Returns list of available screen names.</p>
</dd></dl>

<dl class="function">
<dt id="String[] queryKeyboardModifiers">
<code class="descname">String[] queryKeyboardModifiers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#String[] queryKeyboardModifiers" title="Permalink to this definition"></a></dt>
<dd><p>Returns list of currently pressed keyboard modifiers which can be ‘Ctrl’, ‘Shift’, ‘Alt’, ‘Meta’.</p>
</dd></dl>

<dl class="function">
<dt id="iconColor">
<code class="descname">iconColor</code><span class="sig-paren">(</span><span class="optional">[</span><em>colorName</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#iconColor" title="Permalink to this definition"></a></dt>
<dd><p>Get or set current tray and window icon color name.</p>
<p>Throws exception is the color name is invalid.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="c1">// Flash icon for few moments to get attention.</span>
<span class="kd">var</span> <span class="nx">color</span> <span class="o">=</span> <span class="nx">iconColor</span><span class="p">()</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="p">;</span> <span class="o">++</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span>
  <span class="nx">iconColor</span><span class="p">(</span><span class="s2">&quot;red&quot;</span><span class="p">)</span>
  <span class="nx">sleep</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>
  <span class="nx">iconColor</span><span class="p">(</span><span class="nx">color</span><span class="p">)</span>
  <span class="nx">sleep</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="iconTag">
<code class="descname">iconTag</code><span class="sig-paren">(</span><span class="optional">[</span><em>tag</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#iconTag" title="Permalink to this definition"></a></dt>
<dd><p>Get or set current tray and window tag text.</p>
</dd></dl>

<dl class="function">
<dt id="iconTagColor">
<code class="descname">iconTagColor</code><span class="sig-paren">(</span><span class="optional">[</span><em>colorName</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#iconTagColor" title="Permalink to this definition"></a></dt>
<dd><p>Get or set current tray and window tag color name.</p>
<p>Throws exception is the color name is invalid.</p>
</dd></dl>

<dl class="function">
<dt id="onClipboardChanged">
<code class="descname">onClipboardChanged</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#onClipboardChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when clipboard or X11 selection changes.</p>
<p>Default implementation is:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">runAutomaticCommands</span><span class="p">())</span> <span class="p">{</span>
    <span class="nx">synchronizeSelection</span><span class="p">();</span>
    <span class="nx">saveData</span><span class="p">();</span>
    <span class="nx">updateClipboardData</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
    <span class="nx">clearClipboardData</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="onOwnClipboardChanged">
<code class="descname">onOwnClipboardChanged</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#onOwnClipboardChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when clipboard or X11 selection changes by a CopyQ instance.</p>
<p>Owned clipboard data contains <code class="docutils literal"><span class="pre">mimeOwner</span></code> format.</p>
<p>Default implementation calls <code class="docutils literal"><span class="pre">updateClipboardData()</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="onHiddenClipboardChanged">
<code class="descname">onHiddenClipboardChanged</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#onHiddenClipboardChanged" title="Permalink to this definition"></a></dt>
<dd><p>Called when hidden clipboard or X11 selection changes.</p>
<p>Hidden clipboard data contains <code class="docutils literal"><span class="pre">mimeHidden</span></code> format set to <code class="docutils literal"><span class="pre">1</span></code>.</p>
<p>Default implementation calls <code class="docutils literal"><span class="pre">updateClipboardData()</span></code>.</p>
</dd></dl>

<dl class="function">
<dt id="runAutomaticCommands">
<code class="descname">runAutomaticCommands</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#runAutomaticCommands" title="Permalink to this definition"></a></dt>
<dd><p>Executes automatic commands on current data.</p>
<p>If an executed command calls <code class="docutils literal"><span class="pre">ignore()</span></code> or have “Remove Item” or “Transform”
check box enabled, following automatic commands won’t be executed and the
function returns false. Otherwise true is returned.</p>
</dd></dl>

<dl class="function">
<dt id="updateTitle">
<code class="descname">updateTitle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#updateTitle" title="Permalink to this definition"></a></dt>
<dd><p>Update main window title and tool tip from current data.</p>
<p>Called when clipboard changes.</p>
</dd></dl>

<dl class="function">
<dt id="updateClipboardData">
<code class="descname">updateClipboardData</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#updateClipboardData" title="Permalink to this definition"></a></dt>
<dd><p>Sets current clipboard data for tray menu, window title and notification.</p>
<p>Default implementation is:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">isClipboard</span><span class="p">())</span> <span class="p">{</span>
    <span class="nx">updateTitle</span><span class="p">();</span>
    <span class="nx">showDataNotification</span><span class="p">();</span>
    <span class="nx">setClipboardData</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<code class="descname">updateClipboardData</code><span class="sig-paren">(</span><span class="sig-paren">)</span></dt>
<dd><p>Clears current clipboard data for tray menu, window title and notification.</p>
<p>Default implementation is:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">(</span><span class="nx">isClipboard</span><span class="p">())</span> <span class="p">{</span>
    <span class="nx">setTitle</span><span class="p">();</span>
    <span class="nx">hideDataNotification</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="setTitle">
<code class="descname">setTitle</code><span class="sig-paren">(</span><span class="optional">[</span><em>title</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#setTitle" title="Permalink to this definition"></a></dt>
<dd><p>Set main window title and tool tip.</p>
</dd></dl>

<dl class="function">
<dt id="synchronizeSelection">
<code class="descname">synchronizeSelection</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#synchronizeSelection" title="Permalink to this definition"></a></dt>
<dd><p>Synchronize current data with clipboard and X11 selection
(depends on <cite>mimeSyncToSelection</cite> and <cite>mimeSyncToClipboard</cite>).</p>
</dd></dl>

<dl class="function">
<dt id="saveData">
<code class="descname">saveData</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#saveData" title="Permalink to this definition"></a></dt>
<dd><p>Save current data (depends on <cite>mimeOutputTab</cite>).</p>
</dd></dl>

<dl class="function">
<dt id="showDataNotification">
<code class="descname">showDataNotification</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#showDataNotification" title="Permalink to this definition"></a></dt>
<dd><p>Show notification for current data.</p>
</dd></dl>

<dl class="function">
<dt id="hideDataNotification">
<code class="descname">hideDataNotification</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#hideDataNotification" title="Permalink to this definition"></a></dt>
<dd><p>Hide notification for current data.</p>
</dd></dl>

<dl class="function">
<dt id="setClipboardData">
<code class="descname">setClipboardData</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#setClipboardData" title="Permalink to this definition"></a></dt>
<dd><p>Sets clipboard data for menu commands.</p>
</dd></dl>

</div>
<div class="section" id="types">
<h2>Types<a class="headerlink" href="#types" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="ByteArray">
<em class="property">class </em><code class="descname">ByteArray</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ByteArray" title="Permalink to this definition"></a></dt>
<dd><p>Wrapper for QByteArray Qt class.</p>
<p>See <a class="reference external" href="http://doc.qt.io/qt-5/qbytearray.html">QByteArray</a>.</p>
<p><code class="docutils literal"><span class="pre">ByteArray</span></code> is used to store all item data (image data, HTML and even
plain text).</p>
<p>Use <code class="docutils literal"><span class="pre">str()</span></code> to convert it to string. Strings are usually more
versatile. For example to concatenate two items, the data need to be
converted to strings first.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">text</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="nx">read</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="o">+</span> <span class="nx">str</span><span class="p">(</span><span class="nx">read</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="File">
<em class="property">class </em><code class="descname">File</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#File" title="Permalink to this definition"></a></dt>
<dd><p>Wrapper for QFile Qt class.</p>
<p>See <a class="reference external" href="http://doc.qt.io/qt-5/qfile.html">QFile</a>.</p>
<p>To open file in different modes use:</p>
<ul class="simple">
<li><cite>open()</cite> - read/write</li>
<li><cite>openReadOnly()</cite> - read only</li>
<li><cite>openWriteOnly()</cite> - write only, truncates the file</li>
<li><cite>openAppend()</cite> - write only, appends to the file</li>
</ul>
<p>Following code reads contents of “README.md” file from current
directory.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">File</span><span class="p">(</span><span class="s1">&#39;README.md&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">f</span><span class="p">.</span><span class="nx">openReadOnly</span><span class="p">())</span>
  <span class="nx">raise</span> <span class="s1">&#39;Failed to open the file: &#39;</span> <span class="o">+</span> <span class="nx">f</span><span class="p">.</span><span class="nx">errorString</span><span class="p">()</span>
<span class="kd">var</span> <span class="nx">bytes</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">readAll</span><span class="p">()</span>
</pre></div>
</div>
<p>Following code writes to a file in home directory.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">dataToWrite</span> <span class="o">=</span> <span class="s1">&#39;Hello, World!&#39;</span>
<span class="kd">var</span> <span class="nx">filePath</span> <span class="o">=</span> <span class="nx">Dir</span><span class="p">().</span><span class="nx">homePath</span><span class="p">()</span> <span class="o">+</span> <span class="s1">&#39;/copyq.txt&#39;</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">File</span><span class="p">(</span><span class="nx">filePath</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">f</span><span class="p">.</span><span class="nx">openWriteOnly</span><span class="p">()</span> <span class="o">||</span> <span class="nx">f</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">dataToWrite</span><span class="p">)</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
  <span class="nx">raise</span> <span class="s1">&#39;Failed to save the file: &#39;</span> <span class="o">+</span> <span class="nx">f</span><span class="p">.</span><span class="nx">errorString</span><span class="p">()</span>

<span class="c1">// Always flush the data and close the file,</span>
<span class="c1">// before opening the file in other application.</span>
<span class="nx">f</span><span class="p">.</span><span class="nx">close</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="Dir">
<em class="property">class </em><code class="descname">Dir</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Dir" title="Permalink to this definition"></a></dt>
<dd><p>Wrapper for QDir Qt class.</p>
<p>See <a class="reference external" href="http://doc.qt.io/qt-5/qdir.html">QDir</a>.</p>
</dd></dl>

<dl class="class">
<dt id="TemporaryFile">
<em class="property">class </em><code class="descname">TemporaryFile</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#TemporaryFile" title="Permalink to this definition"></a></dt>
<dd><p>Wrapper for QTemporaryFile Qt class.</p>
<p>See <a class="reference external" href="https://doc.qt.io/qt-5/qtemporaryfile.html">QTemporaryFile</a>.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">TemporaryFile</span><span class="p">()</span>
<span class="nx">f</span><span class="p">.</span><span class="nx">open</span><span class="p">()</span>
<span class="nx">f</span><span class="p">.</span><span class="nx">setAutoRemove</span><span class="p">(</span><span class="kc">false</span><span class="p">)</span>
<span class="nx">popup</span><span class="p">(</span><span class="s1">&#39;New temporary file&#39;</span><span class="p">,</span> <span class="nx">f</span><span class="p">.</span><span class="nx">fileName</span><span class="p">())</span>
</pre></div>
</div>
<p>To open file in different modes, use same open methods as for <cite>File</cite>.</p>
</dd></dl>

<dl class="class">
<dt id="Item">
<em class="property">class </em><code class="descname">Item</code><span class="sig-paren">(</span><em>Object</em><span class="sig-paren">)</span><a class="headerlink" href="#Item" title="Permalink to this definition"></a></dt>
<dd><p>Object with MIME types of an item.</p>
<p>Each property is MIME type with data.</p>
<p>Example:</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">item</span> <span class="o">=</span> <span class="p">{}</span>
<span class="nx">item</span><span class="p">[</span><span class="nx">mimeText</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Hello, World!&#39;</span>
<span class="nx">item</span><span class="p">[</span><span class="nx">mimeHtml</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;&lt;p&gt;Hello, World!&lt;/p&gt;&#39;</span>
<span class="nx">write</span><span class="p">(</span><span class="nx">mimeItems</span><span class="p">,</span> <span class="nx">pack</span><span class="p">(</span><span class="nx">item</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="FinishedCommand">
<em class="property">class </em><code class="descname">FinishedCommand</code><span class="sig-paren">(</span><em>Object</em><span class="sig-paren">)</span><a class="headerlink" href="#FinishedCommand" title="Permalink to this definition"></a></dt>
<dd><p>Properties of finished command.</p>
<p>Properties are:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">stdout</span></code> - standard output</li>
<li><code class="docutils literal"><span class="pre">stderr</span></code> - standard error output</li>
<li><code class="docutils literal"><span class="pre">exit_code</span></code> - exit code</li>
</ul>
</dd></dl>

<dl class="class">
<dt id="NetworkReply">
<em class="property">class </em><code class="descname">NetworkReply</code><span class="sig-paren">(</span><em>Object</em><span class="sig-paren">)</span><a class="headerlink" href="#NetworkReply" title="Permalink to this definition"></a></dt>
<dd><p>Received network reply object.</p>
<p>Properties are:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">data</span></code> - reply data</li>
<li><code class="docutils literal"><span class="pre">error</span></code> - error string (set only if an error occurred)</li>
<li><code class="docutils literal"><span class="pre">redirect</span></code> - URL for redirection (set only if redirection is
needed)</li>
<li><code class="docutils literal"><span class="pre">headers</span></code> - reply headers (array of pairs with header name and
header content)</li>
</ul>
</dd></dl>

<dl class="class">
<dt id="Command">
<em class="property">class </em><code class="descname">Command</code><span class="sig-paren">(</span><em>Object</em><span class="sig-paren">)</span><a class="headerlink" href="#Command" title="Permalink to this definition"></a></dt>
<dd><p>Wrapper for a command (from Command dialog).</p>
<p>Properties are same as members of <a class="reference external" href="https://github.com/hluk/CopyQ/blob/master/src/common/command.h">Command
struct</a>.</p>
</dd></dl>

</div>
<div class="section" id="objects">
<h2>Objects<a class="headerlink" href="#objects" title="Permalink to this headline"></a></h2>
<dl class="data">
<dt id="arguments">
<code class="descname">arguments</code><a class="headerlink" href="#arguments" title="Permalink to this definition"></a></dt>
<dd><p>Array for accessing arguments passed to current function or the script
(<code class="docutils literal"><span class="pre">arguments[0]</span></code> is the script itself).</p>
</dd></dl>

</div>
<div class="section" id="mime-types">
<h2>MIME Types<a class="headerlink" href="#mime-types" title="Permalink to this headline"></a></h2>
<p>Item and clipboard can provide multiple formats for their data. Type of
the data is determined by MIME type.</p>
<p>Here is list of some common and builtin (start with
<code class="docutils literal"><span class="pre">application/x-copyq-</span></code>) MIME types.</p>
<p>These MIME types values are assigned to global variables prefixed with
<code class="docutils literal"><span class="pre">mime</span></code>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Content for following types is UTF-8 encoded.</p>
</div>
<dl class="data">
<dt id="mimeText">
<code class="descname">mimeText</code><a class="headerlink" href="#mimeText" title="Permalink to this definition"></a></dt>
<dd><p>Data contains plain text content.</p>
</dd></dl>

<dl class="data">
<dt id="mimeHtml">
<code class="descname">mimeHtml</code><a class="headerlink" href="#mimeHtml" title="Permalink to this definition"></a></dt>
<dd><p>Data contains HTML content.</p>
</dd></dl>

<dl class="data">
<dt id="mimeUriList">
<code class="descname">mimeUriList</code><a class="headerlink" href="#mimeUriList" title="Permalink to this definition"></a></dt>
<dd><p>Data contains list of links to files, web pages etc.</p>
</dd></dl>

<dl class="data">
<dt id="mimeWindowTitle">
<code class="descname">mimeWindowTitle</code><a class="headerlink" href="#mimeWindowTitle" title="Permalink to this definition"></a></dt>
<dd><p>Current window title for copied clipboard.</p>
</dd></dl>

<dl class="data">
<dt id="mimeItems">
<code class="descname">mimeItems</code><a class="headerlink" href="#mimeItems" title="Permalink to this definition"></a></dt>
<dd><p>Serialized items.</p>
</dd></dl>

<dl class="data">
<dt id="mimeItemNotes">
<code class="descname">mimeItemNotes</code><a class="headerlink" href="#mimeItemNotes" title="Permalink to this definition"></a></dt>
<dd><p>Data contains notes for item.</p>
</dd></dl>

<dl class="data">
<dt id="mimeOwner">
<code class="descname">mimeOwner</code><a class="headerlink" href="#mimeOwner" title="Permalink to this definition"></a></dt>
<dd><p>If available, the clipboard was set from CopyQ (from script or copied items).</p>
<p>Such clipboard is ignored in CopyQ, i.e. it won’t be stored in clipboard
tab and automatic commands won’t be executed on it.</p>
</dd></dl>

<dl class="data">
<dt id="mimeClipboardMode">
<code class="descname">mimeClipboardMode</code><a class="headerlink" href="#mimeClipboardMode" title="Permalink to this definition"></a></dt>
<dd><p>Contains <code class="docutils literal"><span class="pre">selection</span></code> if data is from X11 mouse selection.</p>
</dd></dl>

<dl class="data">
<dt id="mimeCurrentTab">
<code class="descname">mimeCurrentTab</code><a class="headerlink" href="#mimeCurrentTab" title="Permalink to this definition"></a></dt>
<dd><p>Current tab name when invoking command from main window.</p>
<p>Following command print the tab name when invoked from main window.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">copyq</span> <span class="n">data</span> <span class="n">application</span><span class="o">/</span><span class="n">x</span><span class="o">-</span><span class="n">copyq</span><span class="o">-</span><span class="n">current</span><span class="o">-</span><span class="n">tab</span>
<span class="n">copyq</span> <span class="n">selectedTab</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="mimeSelectedItems">
<code class="descname">mimeSelectedItems</code><a class="headerlink" href="#mimeSelectedItems" title="Permalink to this definition"></a></dt>
<dd><p>Selected items when invoking command from main window.</p>
</dd></dl>

<dl class="data">
<dt id="mimeCurrentItem">
<code class="descname">mimeCurrentItem</code><a class="headerlink" href="#mimeCurrentItem" title="Permalink to this definition"></a></dt>
<dd><p>Current item when invoking command from main window.</p>
</dd></dl>

<dl class="data">
<dt id="mimeHidden">
<code class="descname">mimeHidden</code><a class="headerlink" href="#mimeHidden" title="Permalink to this definition"></a></dt>
<dd><p>If set to <code class="docutils literal"><span class="pre">1</span></code>, the clipboard or item content will be hidden in GUI.</p>
<p>This won’t hide notes and tags.</p>
<p>E.g. if you run following, window title and tool tip will be cleared.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">copyq</span> <span class="n">copy</span> <span class="n">application</span><span class="o">/</span><span class="n">x</span><span class="o">-</span><span class="n">copyq</span><span class="o">-</span><span class="n">hidden</span> <span class="mi">1</span> <span class="n">plain</span><span class="o">/</span><span class="n">text</span> <span class="s2">&quot;This is secret&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="mimeShortcut">
<code class="descname">mimeShortcut</code><a class="headerlink" href="#mimeShortcut" title="Permalink to this definition"></a></dt>
<dd><p>Application or global shortcut which activated the command.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">copyq</span><span class="p">:</span>
<span class="n">var</span> <span class="n">shortcut</span> <span class="o">=</span> <span class="n">data</span><span class="p">(</span><span class="n">mimeShortcut</span><span class="p">)</span>
<span class="n">popup</span><span class="p">(</span><span class="s2">&quot;Shortcut Pressed&quot;</span><span class="p">,</span> <span class="n">shortcut</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="mimeColor">
<code class="descname">mimeColor</code><a class="headerlink" href="#mimeColor" title="Permalink to this definition"></a></dt>
<dd><p>Item color (same as the one used by themes).</p>
<p>Examples: #ffff00 rgba(255,255,0,0.5) bg - #000099</p>
</dd></dl>

<dl class="data">
<dt id="mimeOutputTab">
<code class="descname">mimeOutputTab</code><a class="headerlink" href="#mimeOutputTab" title="Permalink to this definition"></a></dt>
<dd><p>Name of the tab where to store new item.</p>
<p>The clipboard data will be stored in tab with this name after all
automatic commands are run.</p>
<p>Clear or remove the format to omit storing the data.</p>
<p>E.g. to omit storing the clipboard data use following in an automatic
command.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">removeData</span><span class="p">(</span><span class="nx">mimeOutputTab</span><span class="p">)</span>
</pre></div>
</div>
<p>Valid only in automatic commands.</p>
</dd></dl>

<dl class="data">
<dt id="mimeSyncToClipboard">
<code class="descname">mimeSyncToClipboard</code><a class="headerlink" href="#mimeSyncToClipboard" title="Permalink to this definition"></a></dt>
<dd><p>If exists the X11 selection data will be copied to clipboard.</p>
<p>The synchronization will happened after all automatic commands are run.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">removeData</span><span class="p">(</span><span class="nx">mimeSyncToClipboard</span><span class="p">)</span>
</pre></div>
</div>
<p>Valid only in Linux/X11 in automatic commands.</p>
</dd></dl>

<dl class="data">
<dt id="mimeSyncToSelection">
<code class="descname">mimeSyncToSelection</code><a class="headerlink" href="#mimeSyncToSelection" title="Permalink to this definition"></a></dt>
<dd><p>If exists the clipboard data will be copied to X11 selection.</p>
<p>The synchronization will happened after all automatic commands are run.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="nx">removeData</span><span class="p">(</span><span class="nx">mimeSyncToSelection</span><span class="p">)</span>
</pre></div>
</div>
<p>Valid only in Linux/X11 in automatic commands.</p>
</dd></dl>

</div>
<div class="section" id="selected-items">
<h2>Selected Items<a class="headerlink" href="#selected-items" title="Permalink to this headline"></a></h2>
<p>Functions that get and set data for selected items and current tab are
only available if called from Action dialog or from a command which is
in menu.</p>
<p>Selected items are indexed from top to bottom as they appeared in the
current tab at the time the command is executed.</p>
</div>
<div class="section" id="plugins">
<h2>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline"></a></h2>
<p>Use <code class="docutils literal"><span class="pre">plugins</span></code> object to access functionality of plugins.</p>
<dl class="function">
<dt id="plugins.itemsync.selectedTabPath">
<code class="descclassname">plugins.itemsync.</code><code class="descname">selectedTabPath</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemsync.selectedTabPath" title="Permalink to this definition"></a></dt>
<dd><p>Returns synchronization path for current tab (mimeCurrentTab).</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">path</span> <span class="o">=</span> <span class="nx">plugins</span><span class="p">.</span><span class="nx">itemsync</span><span class="p">.</span><span class="nx">selectedTabPath</span><span class="p">()</span>
<span class="kd">var</span> <span class="nx">baseName</span> <span class="o">=</span> <span class="nx">str</span><span class="p">(</span><span class="nx">data</span><span class="p">(</span><span class="nx">plugins</span><span class="p">.</span><span class="nx">itemsync</span><span class="p">.</span><span class="nx">mimeBaseName</span><span class="p">))</span>
<span class="kd">var</span> <span class="nx">absoluteFilePath</span> <span class="o">=</span> <span class="nx">Dir</span><span class="p">(</span><span class="nx">path</span><span class="p">).</span><span class="nx">absoluteFilePath</span><span class="p">(</span><span class="nx">baseName</span><span class="p">)</span>
<span class="c1">// NOTE: Known file suffix/extension can be missing in the full path.</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="plugins.itemsync.tabPaths">
<em class="property">class </em><code class="descclassname">plugins.itemsync.</code><code class="descname">tabPaths</code><span class="sig-paren">(</span><em>Object</em><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemsync.tabPaths" title="Permalink to this definition"></a></dt>
<dd><p>Object that maps tab name to synchronization path.</p>
<div class="highlight-js"><div class="highlight"><pre><span></span><span class="kd">var</span> <span class="nx">tabName</span> <span class="o">=</span> <span class="s1">&#39;Downloads&#39;</span>
<span class="kd">var</span> <span class="nx">path</span> <span class="o">=</span> <span class="nx">plugins</span><span class="p">.</span><span class="nx">itemsync</span><span class="p">.</span><span class="nx">tabPaths</span><span class="p">[</span><span class="nx">tabName</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="plugins.itemsync.mimeBaseName">
<code class="descclassname">plugins.itemsync.</code><code class="descname">mimeBaseName</code><a class="headerlink" href="#plugins.itemsync.mimeBaseName" title="Permalink to this definition"></a></dt>
<dd><p>MIME type for accessing base name (without full path).</p>
<p>Known file suffix/extension can be missing in the base name.</p>
</dd></dl>

<dl class="data">
<dt id="plugins.itemtags.userTags">
<code class="descclassname">plugins.itemtags.</code><code class="descname">userTags</code><a class="headerlink" href="#plugins.itemtags.userTags" title="Permalink to this definition"></a></dt>
<dd><p>List of user-defined tags.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itemtags.tags">
<code class="descclassname">plugins.itemtags.</code><code class="descname">tags</code><span class="sig-paren">(</span><em>row</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemtags.tags" title="Permalink to this definition"></a></dt>
<dd><p>List of tags for items in given rows.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itemtags.tag">
<code class="descclassname">plugins.itemtags.</code><code class="descname">tag</code><span class="sig-paren">(</span><em>tagName</em><span class="optional">[</span>, <em>rows</em>, <em>...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemtags.tag" title="Permalink to this definition"></a></dt>
<dd><p>Add given tag to items in given rows or selected items.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itemtags.untag">
<code class="descclassname">plugins.itemtags.</code><code class="descname">untag</code><span class="sig-paren">(</span><em>tagName</em><span class="optional">[</span>, <em>rows</em>, <em>...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemtags.untag" title="Permalink to this definition"></a></dt>
<dd><p>Remove given tag from items in given rows or selected items.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itemtags.clearTags">
<code class="descclassname">plugins.itemtags.</code><code class="descname">clearTags</code><span class="sig-paren">(</span><span class="optional">[</span><em>rows</em>, <em>...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemtags.clearTags" title="Permalink to this definition"></a></dt>
<dd><p>Remove all tags from items in given rows or selected items.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itemtags.hasTag">
<code class="descclassname">plugins.itemtags.</code><code class="descname">hasTag</code><span class="sig-paren">(</span><em>tagName</em><span class="optional">[</span>, <em>rows</em>, <em>...</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itemtags.hasTag" title="Permalink to this definition"></a></dt>
<dd><p>Return true if given tag is present in any of items in given rows or
selected items.</p>
<p>See <a class="reference internal" href="#selected-items">Selected Items</a>.</p>
</dd></dl>

<dl class="data">
<dt id="plugins.itemtags.mimeTags">
<code class="descclassname">plugins.itemtags.</code><code class="descname">mimeTags</code><a class="headerlink" href="#plugins.itemtags.mimeTags" title="Permalink to this definition"></a></dt>
<dd><p>MIME type for accessing list of tags.</p>
<p>Tags are separated by comma.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itempinned.isPinned">
<code class="descclassname">plugins.itempinned.</code><code class="descname">isPinned</code><span class="sig-paren">(</span><em>rows</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itempinned.isPinned" title="Permalink to this definition"></a></dt>
<dd><p>Returns true only if any item in given rows is pinned.</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itempinned.pin">
<code class="descclassname">plugins.itempinned.</code><code class="descname">pin</code><span class="sig-paren">(</span><em>rows</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itempinned.pin" title="Permalink to this definition"></a></dt>
<dd><p>Pin items in given rows or selected items or new item created from clipboard
(if called from automatic command).</p>
</dd></dl>

<dl class="function">
<dt id="plugins.itempinned.unpin">
<code class="descclassname">plugins.itempinned.</code><code class="descname">unpin</code><span class="sig-paren">(</span><em>rows</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#plugins.itempinned.unpin" title="Permalink to this definition"></a></dt>
<dd><p>Unpin items in given rows or selected items.</p>
</dd></dl>

</div>
</div>


           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="build-source-code.html" class="btn btn-neutral float-right" title="Build from Source Code" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="writing-raw-data.html" class="btn btn-neutral" title="Writing Raw Data" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Lukas Holecek.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'./',
            VERSION:'',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="_static/jquery.js"></script>
      <script type="text/javascript" src="_static/underscore.js"></script>
      <script type="text/javascript" src="_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>